Function: term_is_ancestor_of

term_is_ancestor_of( integer | object $term1, integer | object $term2, string $taxonomy )

Check if a term is an ancestor of another term.

Shortcut: tiao

You can use above key combination to trigger the associated snippet for this function in the WordPress Snippets for Visual Studio Code extension. You can also use this shortcut to search for this function on this website.

You can use either an id or the term object for both parameters.

Parameters

Name Type(s) Default Value Description
$term1 integer | object

ID or object to check if this is the parent term.

$term2 integer | object

The child term.

$taxonomy string

Taxonomy name that $term1 and $term2 belong to.

Returns

boolean

Whether $term2 is a child of $term1.

WordPress Developer Newsletter

Stay informed of new chapter releases, important WordPress API updates and more.