Switch language

wpseek.com
A WordPress-centric search engine for devs and theme authors




get_object_taxonomies [ WordPress Function ]

get_object_taxonomies ( $object, $output = 'names' )
Parameters:
  • (array|string|object) $object Name of the type of taxonomy object, or an object (row from posts)
  • (string) $output The type of output to return, either taxonomy 'names' or 'objects'. 'names' is the default.
Uses:
  • $wp_taxonomies
Returns:
  • (array) The names of all taxonomy of $object_type.
Defined at:



Return all of the taxonomy names that are of $object_type.

It appears that this function can be used to find all of the names inside of $wp_taxonomies global variable.

get_object_taxonomies('post'); ?>

Should result in

Array('category', 'post_tag')

Source


<?php
function get_object_taxonomies($object$output 'names') {
    global 
$wp_taxonomies;

    if ( 
is_object($object) ) {
        if ( 
$object->post_type == 'attachment' )
            return 
get_attachment_taxonomies($object);
        
$object $object->post_type;
    }

    
$object = (array) $object;

    
$taxonomies = array();
    foreach ( (array) 
$wp_taxonomies as $tax_name => $tax_obj ) {
        if ( 
array_intersect($object, (array) $tax_obj->object_type) ) {
            if ( 
'names' == $output )
                
$taxonomies[] = $tax_name;
            else
                
$taxonomies$tax_name ] = $tax_obj;
        }
    }

    return 
$taxonomies;
}
?>

Examples [ wp-snippets.com ]

Top Google Search Results

More ...

User discussions [ wordpress.org ]

0 User Note(s)

None yet. Be the first!

Add New ...



HTML5 Powered with CSS3 / Styling, Performance & Integration, and Semantics