Languages: English • 日本語 (Add your language)
Get a list of registered taxonomy objects.
<?php get_taxonomies( $args, $output, $operator ) ?>
Array ( [special_taxonomy] => special_taxonomy [custom_taxonomy] => custom_taxonomy )
If returning objects, you will get an array of objects such as:
Array ( [special_taxonomy] => stdClass Object [custom_taxonomy] => stdClass Object )
wherein each object will contain the following fields:
stdClass Object ( [hierarchical] => [update_count_callback] => [rewrite] => [query_var] => [public] => [show_ui] => [show_tagcloud] => [_builtin] => [labels] => stdClass Object ( [name] => [singular_name] => [search_items] => [popular_items] => [all_items] => [parent_item] => [parent_item_colon] => [edit_item] => [view_item] => [update_item] => [add_new_item] => [new_item_name] => [separate_items_with_commas] => [add_or_remove_items] => [choose_from_most_used] => [menu_name] => [name_admin_bar] => ) [show_in_nav_menus] => [cap] => stdClass Object ( [manage_terms] => [edit_terms] => [delete_terms] => [assign_terms] => ) [name] => [object_type] => Array () [label] )
The call to get_taxonomies returns the registered taxonomies.
<?php $taxonomies = get_taxonomies(); ?>
<?php $taxonomies = get_taxonomies(); foreach ( $taxonomies as $taxonomy ) { echo '<p>' . $taxonomy . '</p>'; } ?>
This return all custom (not builtin) taxonomies.
<?php $args = array( 'public' => true, '_builtin' => false ); $output = 'names'; // or objects $operator = 'and'; // 'and' or 'or' $taxonomies = get_taxonomies( $args, $output, $operator ); if ( $taxonomies ) { foreach ( $taxonomies as $taxonomy ) { echo '<p>' . $taxonomy . '</p>'; } } ?>
This example uses the 'object' output to retrieve and display the taxonomy called 'genre':
<?php $args=array( 'name' => 'genre' ); $output = 'objects'; // or names $taxonomies=get_taxonomies($args,$output); if ($taxonomies) { foreach ($taxonomies as $taxonomy ) { echo '<p>' . $taxonomy->name . '</p>'; } } ?>
get_taxonomies() is located in wp-includes/taxonomy.php
.