检索为附件注册的所有分类名称。
原型
get_taxonomies_for_attachments( string $output = 'names' )
描述
处理哑剧类型特定的分类法,例如附件:图像和附件:视频。
参考:
- get_taxonomies()
参数
$output
(string)
(Optional)
要返回的分类输出的类型。接受’名字’或’对象’。
返回值
(array)
$ object_type的所有分类的名称。
源文件
路径:wp-includes/media.php
<?php
...
function get_taxonomies_for_attachments( $output = 'names' ) {
$taxonomies = array();
foreach ( get_taxonomies( array(), 'objects' ) as $taxonomy ) {
foreach ( $taxonomy->object_type as $object_type ) {
if ( 'attachment' == $object_type || 0 === strpos( $object_type, 'attachment:' ) ) {
if ( 'names' == $output )
$taxonomies[] = $taxonomy->name;
else
$taxonomies[ $taxonomy->name ] = $taxonomy;
break;
}
}
}
return $taxonomies;
}
...
?>
其他
英文文档:https://developer.wordpress.org/reference/functions/get_taxonomies_for_attachments/