get_taxonomy() WordPress Function

The get_taxonomy() function is used to retrieve information about a given taxonomy. This function can be used to get information about both built-in taxonomies (such as categories and tags) and custom taxonomies. The get_taxonomy() function takes a single parameter, the name of the taxonomy, and returns an object containing information about the taxonomy.

get_taxonomy( string $taxonomy ) #

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.


Top ↑

Parameters

$taxonomy

(string)(Required)Name of taxonomy object to return.


Top ↑

Return

(WP_Taxonomy|false) The taxonomy object or false if $taxonomy doesn't exist.


Top ↑

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


Top ↑

Source

File: wp-includes/taxonomy.php

function get_taxonomy( $taxonomy ) {
	global $wp_taxonomies;

	if ( ! taxonomy_exists( $taxonomy ) ) {
		return false;
	}

	return $wp_taxonomies[ $taxonomy ];
}


Top ↑

Changelog

Changelog
VersionDescription
2.3.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.

Show More
Show More