wpseek.com
Uma área de pesquisa sobre o WordPress para devs e autores do tema
term_is_ancestor_of › WordPress Function
Desde3.4.0
Obsoleton/a
› term_is_ancestor_of ( $term1, $term2, $taxonomy )
| Parâmetros: (3) |
|
| Retorna: |
|
| Definido em: |
|
| Codex: |
Checks if a term is an ancestor of another term.
You can use either an ID or the term object for both parameters.Funções relacionadas: cat_is_ancestor_of, get_post_ancestors, get_ancestors, _get_post_ancestors, permalink_anchor
Fonte
function term_is_ancestor_of( $term1, $term2, $taxonomy ) {
if ( ! isset( $term1->term_id ) ) {
$term1 = get_term( $term1, $taxonomy );
}
if ( ! isset( $term2->parent ) ) {
$term2 = get_term( $term2, $taxonomy );
}
if ( empty( $term1->term_id ) || empty( $term2->parent ) ) {
return false;
}
if ( $term2->parent === $term1->term_id ) {
return true;
}
return term_is_ancestor_of( $term1, get_term( $term2->parent, $taxonomy ), $taxonomy );
}