Languages: English • object taxonomies 日本語 (Add your language)
Returns all the taxonomies for a post type or post object
<?php get_object_taxonomies( $object, $output ); ?>
If the $output parameter is 'objects', taxonomy objects will be returned as described in get_taxonomies()
<?php $taxonomy_objects = get_object_taxonomies( 'post', 'objects' ); print_r( $taxonomy_objects); ?>
will output
Array
(
[category] => stdClass Object
(
[hierarchical] => 1
[update_count_callback] =>
[rewrite] =>
[query_var] => category_name
[public] => 1
[show_ui] => 1
[show_tagcloud] => 1
[_builtin] => 1
[labels] => stdClass Object
(
...
)
...
[name] => category
[label] => Categories
)
[post_tag] => stdClass Object
(
...
)
[post_format] => stdClass Object
(
....
)
)
To get the taxonomies for the current post, the current post object can be passed instead of the post type
<?php
function get_current_post_taxonomies(){
global $post;
$taxonomy_names = get_object_taxonomies( $post );
print_r( $taxonomy_names );
}
add_action('wp_head','get_current_post_taxonomies');
?>
will output
Array
(
[0] => category
[1] => post_tag
[2] => post_format
)
Since: 2.3.0
get_object_taxonomies() is located in wp-includes/taxonomy.php.