Retrieves the taxonomy object of $taxonomy.
Description
The get_taxonomy function will first check that the parameter string given is a taxonomy object and if it is, it will return it.
Parameters
$taxonomy
stringrequired- Name of taxonomy object to return.
Return
WP_Taxonomy|false The taxonomy object or false if $taxonomy doesn’t exist.More Information
Note that it does NOT return the list of terms associated with the taxonomy. To do this, you should use get_term() to return an object or wp_list_categories() to return an HTML list of terms
Source
function get_taxonomy( $taxonomy ) {
global $wp_taxonomies;
if ( ! taxonomy_exists( $taxonomy ) ) {
return false;
}
return $wp_taxonomies[ $taxonomy ];
}
Related
Uses | Description |
---|---|
taxonomy_exists()wp-includes/taxonomy.php | Determines whether the taxonomy name exists. |
Used by | Description |
---|---|
_wp_build_title_and_description_for_taxonomy_block_template()wp-includes/block-template-utils.php | Builds the title and description of a taxonomy-specific template based on the underlying entity referenced. |
WP_REST_Menu_Items_Controller::prepare_item_for_database()wp-includes/rest-api/endpoints/class-wp-rest-menu-items-controller.php | Prepares a single nav menu item for create or update. |
rest_get_route_for_taxonomy_items()wp-includes/rest-api.php | Gets the REST API route for a taxonomy. |
is_taxonomy_viewable()wp-includes/taxonomy.php | Determines whether a taxonomy is considered “viewable”. |
register_and_do_post_meta_boxes()wp-admin/includes/meta-boxes.php | Registers the default post meta boxes, and runs the |
WP_REST_Terms_Controller::check_is_taxonomy_allowed()wp-includes/rest-api/endpoints/class-wp-rest-terms-controller.php | Checks that the taxonomy is valid. |
WP_REST_Terms_Controller::prepare_links()wp-includes/rest-api/endpoints/class-wp-rest-terms-controller.php | Prepares links for the request. |
WP_REST_Terms_Controller::get_item_schema()wp-includes/rest-api/endpoints/class-wp-rest-terms-controller.php | Retrieves the term’s schema, conforming to JSON Schema. |
WP_REST_Terms_Controller::get_collection_params()wp-includes/rest-api/endpoints/class-wp-rest-terms-controller.php | Retrieves the query params for collections. |
WP_REST_Terms_Controller::create_item_permissions_check()wp-includes/rest-api/endpoints/class-wp-rest-terms-controller.php | Checks if a request has access to create a term. |
WP_REST_Terms_Controller::__construct()wp-includes/rest-api/endpoints/class-wp-rest-terms-controller.php | Constructor. |
WP_REST_Terms_Controller::get_items_permissions_check()wp-includes/rest-api/endpoints/class-wp-rest-terms-controller.php | Checks if a request has access to read terms in the specified taxonomy. |
WP_REST_Terms_Controller::get_items()wp-includes/rest-api/endpoints/class-wp-rest-terms-controller.php | Retrieves terms associated with a taxonomy. |
WP_REST_Taxonomies_Controller::get_item_permissions_check()wp-includes/rest-api/endpoints/class-wp-rest-taxonomies-controller.php | Checks if a given request has access to a taxonomy. |
WP_REST_Taxonomies_Controller::get_item()wp-includes/rest-api/endpoints/class-wp-rest-taxonomies-controller.php | Retrieves a specific taxonomy. |
WP_Customize_Nav_Menu_Item_Setting::get_type_label()wp-includes/customize/class-wp-customize-nav-menu-item-setting.php | Get type label. |
WP_Posts_List_Table::categories_dropdown()wp-admin/includes/class-wp-posts-list-table.php | Displays a categories drop-down for filtering on the Posts list table. |
unregister_taxonomy()wp-includes/taxonomy.php | Unregisters a taxonomy. |
WP_Customize_Nav_Menus::search_available_items_query()wp-includes/class-wp-customize-nav-menus.php | Performs post queries for available-item searching. |
WP_Customize_Nav_Menus::load_available_items_query()wp-includes/class-wp-customize-nav-menus.php | Performs the post_type and taxonomy queries for loading available menu items. |
WP_Posts_List_Table::column_default()wp-admin/includes/class-wp-posts-list-table.php | Handles the default column output. |
WP_Media_List_Table::column_default()wp-admin/includes/class-wp-media-list-table.php | Handles output for the default column. |
WP_Terms_List_Table::no_items()wp-admin/includes/class-wp-terms-list-table.php | |
get_the_archive_title()wp-includes/general-template.php | Retrieves the archive title based on the queried object. |
WP_Links_List_Table::extra_tablenav()wp-admin/includes/class-wp-links-list-table.php | |
get_inline_data()wp-admin/includes/template.php | Adds hidden fields with the data for use in the inline editor for posts and pages. |
wp_terms_checklist()wp-admin/includes/template.php | Outputs an unordered list of checkbox input elements labelled with term names. |
wp_popular_terms_checklist()wp-admin/includes/template.php | Retrieves a list of the most popular terms from the specified taxonomy. |
get_attachment_fields_to_edit()wp-admin/includes/media.php | Retrieves the attachment fields to edit form fields. |
get_compat_media_markup()wp-admin/includes/media.php | |
_wp_translate_postdata()wp-admin/includes/post.php | Renames |
edit_post()wp-admin/includes/post.php | Updates an existing post with values provided in |
bulk_edit_posts()wp-admin/includes/post.php | Processes the post data for the bulk editing of posts. |
wp_ajax_inline_save()wp-admin/includes/ajax-actions.php | Handles Quick Edit saving a post from a list table via AJAX. |
wp_ajax_inline_save_tax()wp-admin/includes/ajax-actions.php | Handles Quick Edit saving for a term via AJAX. |
_wp_ajax_add_hierarchical_term()wp-admin/includes/ajax-actions.php | Handles adding a hierarchical term via AJAX. |
wp_ajax_add_link_category()wp-admin/includes/ajax-actions.php | Handles adding a link category via AJAX. |
wp_ajax_add_tag()wp-admin/includes/ajax-actions.php | Handles adding a tag via AJAX. |
wp_ajax_get_tagcloud()wp-admin/includes/ajax-actions.php | Handles getting a tagcloud via AJAX. |
wp_ajax_ajax_tag_search()wp-admin/includes/ajax-actions.php | Handles tag search via AJAX. |
post_tags_meta_box()wp-admin/includes/meta-boxes.php | Displays post tags form fields. |
post_categories_meta_box()wp-admin/includes/meta-boxes.php | Displays post categories form fields. |
WP_Media_List_Table::get_columns()wp-admin/includes/class-wp-media-list-table.php | |
WP_Terms_List_Table::column_posts()wp-admin/includes/class-wp-terms-list-table.php | |
WP_Terms_List_Table::inline_edit()wp-admin/includes/class-wp-terms-list-table.php | Outputs the hidden row displayed when inline editing |
WP_Terms_List_Table::__construct()wp-admin/includes/class-wp-terms-list-table.php | Constructor. |
WP_Terms_List_Table::ajax_user_can()wp-admin/includes/class-wp-terms-list-table.php | |
WP_Terms_List_Table::get_bulk_actions()wp-admin/includes/class-wp-terms-list-table.php | |
wp_nav_menu_item_taxonomy_meta_box()wp-admin/includes/nav-menu.php | Displays a meta box for a taxonomy menu item. |
WP_Posts_List_Table::inline_edit()wp-admin/includes/class-wp-posts-list-table.php | Outputs the hidden row displayed when inline editing |
WP_Posts_List_Table::get_columns()wp-admin/includes/class-wp-posts-list-table.php | |
map_meta_cap()wp-includes/capabilities.php | Maps a capability to the primitive capabilities required of the given user to satisfy the capability being checked. |
wp_list_categories()wp-includes/category-template.php | Displays or retrieves the HTML list of categories. |
feed_links_extra()wp-includes/general-template.php | Displays the links to the extra feeds such as category feeds. |
wp_title()wp-includes/general-template.php | Displays or retrieves page title for all areas of blog. |
WP_Widget_Tag_Cloud::widget()wp-includes/widgets/class-wp-widget-tag-cloud.php | Outputs the content for the current Tag Cloud widget instance. |
_pad_term_counts()wp-includes/taxonomy.php | Adds count of children to parent count. |
get_term_link()wp-includes/taxonomy.php | Generates a permalink for a taxonomy term archive. |
get_the_taxonomies()wp-includes/taxonomy.php | Retrieves all taxonomies associated with a post. |
wp_update_term_count_now()wp-includes/taxonomy.php | Performs term count update immediately. |
wp_get_object_terms()wp-includes/taxonomy.php | Retrieves the terms associated with the given object(s), in the supplied taxonomies. |
wp_set_object_terms()wp-includes/taxonomy.php | Creates term and taxonomy relationships. |
wp_delete_term()wp-includes/taxonomy.php | Removes a term from the database. |
is_taxonomy_hierarchical()wp-includes/taxonomy.php | Determines whether the taxonomy object is hierarchical. |
get_term_feed_link()wp-includes/link-template.php | Retrieves the feed link for a term. |
get_edit_term_link()wp-includes/link-template.php | Retrieves the URL for editing a given term. |
edit_term_link()wp-includes/link-template.php | Displays or retrieves the edit term link with formatting. |
wp_admin_bar_edit_menu()wp-includes/admin-bar.php | Provides an edit link for posts and terms. |
wp_insert_post()wp-includes/post.php | Inserts or update a post. |
redirect_canonical()wp-includes/canonical.php | Redirects incoming links to the proper URL based on the site url. |
_post_format_request()wp-includes/post-formats.php | Filters the request to allow for the format prefix. |
wp_setup_nav_menu_item()wp-includes/nav-menu.php | Decorates a menu item object with the shared navigation menu item properties. |
wp_xmlrpc_server::wp_newTerm()wp-includes/class-wp-xmlrpc-server.php | Creates a new term. |
wp_xmlrpc_server::wp_editTerm()wp-includes/class-wp-xmlrpc-server.php | Edits a term. |
wp_xmlrpc_server::wp_deleteTerm()wp-includes/class-wp-xmlrpc-server.php | Deletes a term. |
wp_xmlrpc_server::wp_getTerm()wp-includes/class-wp-xmlrpc-server.php | Retrieves a term. |
wp_xmlrpc_server::wp_getTerms()wp-includes/class-wp-xmlrpc-server.php | Retrieves all terms for a taxonomy. |
wp_xmlrpc_server::wp_getTaxonomy()wp-includes/class-wp-xmlrpc-server.php | Retrieves a taxonomy. |
Changelog
Version | Description |
---|---|
2.3.0 | Introduced. |
For example for a custom taxonomy named “features” associated with a custom post type named “rentals”.
Result: