wp_get_term_taxonomy_parent_id() WordPress Function

The wp_get_term_taxonomy_parent_id() function is used to get the parent term taxonomy ID for a given term taxonomy ID. This function can be useful when you need to know the parent term taxonomy ID for a given term taxonomy, for example when displaying a list of terms with their parent term taxonomies.

wp_get_term_taxonomy_parent_id( int $term_id, string $taxonomy ) #

Returns the term’s parent’s term ID.


Parameters

$term_id

(int)(Required)Term ID.

$taxonomy

(string)(Required)Taxonomy name.


Top ↑

Return

(int|false) Parent term ID on success, false on failure.


Top ↑

Source

File: wp-includes/taxonomy.php

function wp_get_term_taxonomy_parent_id( $term_id, $taxonomy ) {
	$term = get_term( $term_id, $taxonomy );
	if ( ! $term || is_wp_error( $term ) ) {
		return false;
	}
	return (int) $term->parent;
}


Top ↑

Changelog

Changelog
VersionDescription
3.1.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