函数原型
get_taxonomies_for_attachments( string $output = ‘names’ ): string[]|WP_Taxonomy[]
函数描述
Retrieves all of the taxonomies that are registered for attachments.
是否弃用
未弃用
函数参数
-
$output
string
Optional - The type of taxonomy output to return. Accepts
'names'or'objects'.
Default'names'.Default:
'names'
函数返回值
string[]|WP_Taxonomy[] Array of names or objects of registered taxonomies for attachments.
函数位置
File: wp-includes/media.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;
}
源码链接
变更日志
| Version | Description |
|---|---|
| 3.5.0 | Introduced. |

