is_taxonomy_hierarchical() WordPress Function

The is_taxonomy_hierarchical() function is used to check if a given taxonomy is hierarchical. A taxonomy is hierarchical if it has parent terms and child terms.

is_taxonomy_hierarchical( string $taxonomy ) #

Determines whether the taxonomy object is hierarchical.


Description

Checks to make sure that the taxonomy is an object first. Then Gets the object, and finally returns the hierarchical value in the object.

A false return value might also mean that the taxonomy does not exist.

For more information on this and similar theme functions, check out the Conditional Tags article in the Theme Developer Handbook.


Top ↑

Parameters

$taxonomy

(string)(Required)Name of taxonomy object.


Top ↑

Return

(bool) Whether the taxonomy is hierarchical.


Top ↑

Source

File: wp-includes/taxonomy.php

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

	$taxonomy = get_taxonomy( $taxonomy );
	return $taxonomy->hierarchical;
}


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