Function: _get_term_children

_get_term_children( integer $term_id, array $terms, string $taxonomy, array $ancestors )

Get the subset of $terms that are descendants of $term_id.

Shortcut: gtc

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.

If $terms is an array of objects, then _get_term_children() returns an array of objects. If $terms is an array of IDs, then _get_term_children() returns an array of IDs.


Name Type(s) Default Value Description
$term_id integer

The ancestor term: all returned terms should be descendants of $term_id.

$terms array

The set of terms - either an array of term objects or term IDs - from which those that are descendants of $term_id will be chosen.

$taxonomy string

The taxonomy which determines the hierarchy of the terms.

$ancestors array array()

Optional. Term ancestors that have already been identified. Passed by reference, to keep track of found terms when recursing the hierarchy. The array of located ancestors is used to prevent infinite recursion loops. For performance, term_ids are used as array keys, with 1 as value. Default empty array.


array | WP_Error

The subset of $terms that are descendants of $term_id.

WordPress Developer Newsletter

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