Uses
Uses | Description |
---|---|
wp-includes/taxonomy.php: get_taxonomies() | Retrieves a list of registered taxonomy names or objects. |
Retrieves all of the taxonomies that are registered for attachments.
Handles mime-type-specific taxonomies such as attachment:image and attachment:video.
(string) (Optional) The type of taxonomy output to return. Accepts 'names' or 'objects'.
Default value: '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. |
© 2003–2019 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/get_taxonomies_for_attachments