wp_get_term_taxonomy_parent_id( int $term_id, string $taxonomy ): int|false

In this article

Returns the term’s parent’s term ID.

Parameters

$term_idintrequired
Term ID.
$taxonomystringrequired
Taxonomy name.

Return

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

Source

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;
}

Changelog

VersionDescription
3.1.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.