get_taxonomies_for_attachments()
最后更新于:2021-11-27 00:51:53
get_taxonomies_for_attachments( string$output=’names’)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 value: ‘names’
响应
(string[]|GC_Taxonomy[]) Array of names or objects of registered taxonomies for attachments.
源文件
文件: gc-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;
}