WordPress: reperire le tassonomie discendenti da una data tassonomia
In WordPress possiamo facilmente reperire le tassonomie discendenti da una data tassonomia.
In WordPress possiamo facilmente reperire le tassonomie discendenti da una data tassonomia.
Possiamo usare la funzione get_term_children() che restituisce un array contenente gli ID delle tassonomie discendenti.
$parent_taxonomy_id = 84;
$taxonomy_name = 'taxonomy';
$term_children = get_term_children( $parent_taxonomy_id, $taxonomy_name );
foreach( $term_children as $term_child ) {
$child = get_term_by( 'id', $term_child, $taxonomy_name );
echo $child->name;
}
Commenti