get_taxonomies( array $args = array(), string $output = 'names', string $operator = 'and' ): string[]|WP_Taxonomy[]
- Since
- 3.0.0
- Source
wp-includes/taxonomy.php:282
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
$argsarrayoptional- An array of
key => valuearguments to match against the taxonomy objects.
Default empty array.Default:array() $outputstringoptional- The type of output to return in the array. Either 'names' or 'objects'. Default 'names'.Default:
'names' $operatorstringoptional- The logical operation to perform. Accepts 'and' or 'or'. 'or' means only one element from the array needs to match; 'and' means all elements must match.
Default 'and'.Default:'and'
Return value
string[]|WP_Taxonomy[]- An array of taxonomy names or objects.
Performance profile
How much work a call to get_taxonomies() 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
- 15–16
- Plugin surface
- None
- Called by
- 22
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 17.
Nothing here hands control to plugin code.
22 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 get_taxonomies() can have, taken from its control-flow graph on PHP 8.5.
| When | Instructions | Calls it makes |
|---|---|---|
| always | 15–16 | wp_filter_object_list() |
Across PHP versions
Compiles the same on PHP 7.4, 8.1, 8.2, 8.3, 8.4, 8.5 and 8.6-dev: 17 instructions, 15–16 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.
Uses · 1
- wp_filter_object_list()Filters a list of objects, based on a set of key => value arguments.
Used by · 22
- WP::parse_request()Parses the request to find the correct WordPress query.
- WP_Customize_Nav_Menus::available_item_types()Returns an array of all the available item types.
- WP_Customize_Nav_Menus::search_available_items_query()Performs post queries for available-item searching.
- WP_Query::parse_tax_query()Parses various taxonomy related query vars.
- WP_REST_Taxonomies_Controller::get_items()Retrieves all public taxonomies.
- WP_REST_Taxonomies_Controller::get_items_permissions_check()Checks whether a given request has permission to read taxonomies.
- WP_REST_Term_Search_Handler::__construct()Constructor.
- WP_Sitemaps_Taxonomies::get_object_subtypes()Returns all public, registered taxonomies.
- WP_Widget_Tag_Cloud::form()Outputs the Tag Cloud widget settings form.
- _build_block_template_result_from_post()Builds a unified template object based a post Object.
- block_core_navigation_link_build_variations()Returns an array of variations for the navigation link block.
- block_core_post_terms_build_variations()Returns the available variations for the `core/post-terms` block.
Show all 22
- create_initial_rest_routes()Registers default REST API routes.
- export_wp()Generates the WXR export file for download.
- get_post_class()Retrieves an array of the class names for the post container element.
- get_taxonomies_for_attachments()Retrieves all of the taxonomies that are registered for attachments.
- get_template_hierarchy()Gets the template hierarchy for the given template slug to be created.
- set_screen_options()Saves option for number of rows when listing posts, pages, comments, etc.
- upgrade_350()Execute changes made in WordPress 3.5.
- wp_ajax_menu_get_metabox()Handles for retrieving menu meta boxes via AJAX.
- wp_nav_menu_taxonomy_meta_boxes()Creates meta boxes for any taxonomy menu item.
- wp_xmlrpc_server::wp_getTaxonomies()Retrieves all taxonomies.
Source code
function get_taxonomies( $args = array(), $output = 'names', $operator = 'and' ) { global $wp_taxonomies; $field = ( 'names' === $output ) ? 'name' : false; return wp_filter_object_list( $wp_taxonomies, $args, $operator, $field );}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 6.8.8 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.