get_taxonomies_for_attachments() WP 3.5.0
Retrieves all of the taxonomies that are registered for attachments.
Handles mime-type-specific taxonomies such as attachment:image and attachment:video.
Хуков нет.
Возвращает
Строку[]/WP_Taxonomy[]. Array of names or objects of registered taxonomies for attachments.
Использование
get_taxonomies_for_attachments( $output );
- $output(строка)
- The type of taxonomy output to return. Accepts 'names' or 'objects'.
По умолчанию: 'names'
Заметки
- Смотрите: get_taxonomies()
Список изменений
С версии 3.5.0 | Введена. |
Код get_taxonomies_for_attachments() get taxonomies for attachments WP 5.6.2
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;
}