get_taxonomies_for_attachments

Retrieves all of the taxonomy names that are registered for attachments.

Description

(array) get_taxonomies_for_attachments( (string) $output = 'names' ); 

Handles mime-type-specific taxonomies such as attachment:image and attachment:video.

Returns (array)

The names of all taxonomy of $object_type.

Parameters (1)

0. $output — Optional. (string) => 'names'
The type of taxonomy output to return. Accepts names or objects.. Default names .

Usage

  1. if ( !function_exists( 'get_taxonomies_for_attachments' ) ) { 
  2. require_once ABSPATH . WPINC . '/media.php'; 
  3.  
  4. // Optional. The type of taxonomy output to return. Accepts 'names' or 'objects'. 
  5. // Default 'names'. 
  6. $output = 'names'; 
  7.  
  8. // NOTICE! Understand what this does before running. 
  9. $result = get_taxonomies_for_attachments($output); 
  10.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/media.php  
  1. function get_taxonomies_for_attachments( $output = 'names' ) { 
  2. $taxonomies = array(); 
  3. foreach ( get_taxonomies( array(), 'objects' ) as $taxonomy ) { 
  4. foreach ( $taxonomy->object_type as $object_type ) { 
  5. if ( 'attachment' == $object_type || 0 === strpos( $object_type, 'attachment:' ) ) { 
  6. if ( 'names' == $output ) 
  7. $taxonomies[] = $taxonomy->name; 
  8. else 
  9. $taxonomies[ $taxonomy->name ] = $taxonomy; 
  10. break; 
  11.  
  12. return $taxonomies;