taxonomy_exists( string $taxonomy ): bool
- Since
- 3.0.0
- Source
wp-includes/taxonomy.php:376
Description
Formerly is_taxonomy(), introduced in 2.3.0.
For more information on this and similar theme functions, check out the https://developer.wordpress.org/themes/basics/conditional-tags/ Conditional Tags article in the Theme Developer Handbook.
Compatibility
- WordPress
- since 3.0.0
- PHP
- 7.4–8.6-dev
- 6.7.7
- 6.8.8
- 6.9.7
- 7.0.4
- 7.1.0
Present in every tracked release (6.7.7 to 7.1.0), and compiles on PHP 7.4 through 8.6-dev.
Parameters
$taxonomystring- Name of taxonomy object.
Return value
bool- Whether the taxonomy exists.
Performance profile
How much work a call to taxonomy_exists() does, and what it touches: the algorithmic scaling, the Zend instruction count per call across PHP versions, the hooks it hands control to, and the core code that calls it. Measured from the compiled opcodes, not a stopwatch, so every number is identical on any machine running the same PHP version, and every function in core is ranked by cost.
- Cost class
- Trivial
- Scaling
- Constant
- Instructions
- 5–6
- Plugin surface
- None
- Called by
- 32
Touches nothing outside its own arguments.
No loop in the body: the same number of instructions runs whatever you pass in.
Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 6.
Nothing here hands control to plugin code.
32 places in core call this, so the cost is paid more often than your own code shows.
What one call costs · 1 distinct outcome
One number would be a lie: the work depends on which branch runs. These are every distinct cost taxonomy_exists() can have, taken from its control-flow graph on PHP 8.5.
| When | Instructions | Calls it makes |
|---|---|---|
| always | 5–6 | none |
Across PHP versions
Compiles the same on PHP 7.4, 8.1, 8.2, 8.3, 8.4, 8.5 and 8.6-dev: 6 instructions, 5–6 executed per call, 1 branch. The work does not change between versions.
An instruction is not a fixed amount of time, so a matching count is not necessarily the same speed; what it rules out is a difference in the work itself.
Used by · 32
- WP_Customize_Nav_Menu_Item_Setting::populate_value()Ensure that the value is fully populated with the necessary properties.
- WP_Screen::get()Fetches a screen object.
- WP_Tax_Query::clean_query()Validates a single query.
- WP_Term::get_instance()Retrieve WP_Term instance.
- WP_Terms_List_Table::__construct()Constructor.
- WP_Widget_Tag_Cloud::_get_current_taxonomy()Retrieves the taxonomy for the current Tag cloud widget instance.
- _wp_ajax_menu_quick_search()Prints the appropriate response to a menu quick search.
- get_adjacent_post()Retrieves the adjacent post.
- get_boundary_post()Retrieves the boundary post.
- get_objects_in_term()Retrieves object IDs of valid taxonomy and term.
- get_taxonomy()Retrieves the taxonomy object of $taxonomy.
- get_term()Gets all term data from database by term ID.
Show all 32
- get_term_by()Gets all term data from database by term field and data.
- get_term_children()Merges all term children into a single array of their IDs.
- get_terms()Retrieves the terms in a given taxonomy or list of taxonomies.
- is_taxonomy()Checks that the taxonomy name exists.
- is_taxonomy_hierarchical()Determines whether the taxonomy object is hierarchical.
- unregister_taxonomy()Unregisters a taxonomy.
- wp_count_terms()Counts how many terms are in taxonomy.
- wp_get_nav_menu_items()Retrieves all menu items of a navigation menu.
- wp_get_object_terms()Retrieves the terms associated with the given object(s), in the supplied taxonomies.
- wp_insert_term()Adds a new term to the database.
- wp_list_categories()Displays or retrieves the HTML list of categories.
- wp_remove_object_terms()Removes term(s) associated with a given object.
- wp_set_object_terms()Creates term and taxonomy relationships.
- wp_update_term()Updates term based on arguments provided.
- wp_xmlrpc_server::wp_deleteTerm()Deletes a term.
- wp_xmlrpc_server::wp_editTerm()Edits a term.
- wp_xmlrpc_server::wp_getTaxonomy()Retrieves a taxonomy.
- wp_xmlrpc_server::wp_getTerm()Retrieves a term.
- wp_xmlrpc_server::wp_getTerms()Retrieves all terms for a taxonomy.
- wp_xmlrpc_server::wp_newTerm()Creates a new term.
Source code
function taxonomy_exists( $taxonomy ) { global $wp_taxonomies; return is_string( $taxonomy ) && isset( $wp_taxonomies[ $taxonomy ] );}Changelog
Introduced in 3.0.0. Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
About this page
- Parsed data
- Generated from the wordpress-develop 7.0.4 tag, from
src/wp-includes/taxonomy.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it. - Corrections
- Something wrong on this page? Report it and it gets fixed in the next regeneration.