WordPress at Your Fingertips

wp_get_term_taxonomy_parent_id() WP 1.0

Returns the term's parent's term_ID.

Uses: get_term()

No Hooks.

Return

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

Usage

wp_get_term_taxonomy_parent_id( $term_id, $taxonomy );
$term_id(int) (required)
Term ID.
$taxonomy(string) (required)
Taxonomy name.

Changelog

Since 3.1.0 Introduced.

Code of wp_get_term_taxonomy_parent_id() WP 5.8.1

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

Term (taxonomies terms)

Any taxonomy

No comments
    Log In