Switch language

wpseek.com
A WordPress-centric search engine for devs and theme authors




term_is_ancestor_of [ WordPress Function ]

term_is_ancestor_of ( $term1, $term2, $taxonomy )
Parameters:
  • (int|object) $term1 ID or object to check if this is the parent term.
  • (int|object) $term2 The child term.
  • (string) $taxonomy Taxonomy name that $term1 and $term2 belong to.
Returns:
  • (bool) Whether $term2 is child of $term1
Defined at:



Check if a term is an ancestor of another term.

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

Source


<?php
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$term1get_term$term2->parent$taxonomy ), $taxonomy );
}
?>

Examples [ wp-snippets.com ]

Google Arama Sonuçlarý

Dahasý ...

Kullanýcý Tartýþmalarý [ wordpress.org ]

- Bulunamadý -

Yeni bir konu yaz ...

0 User Note(s)

Henüz yok. Ýlk sen ol!

Yeni Ekle ...



HTML5 Powered with CSS3 / Styling, Performance & Integration, and Semantics