d2321
5/15/2020 - 1:15 PM

Determine term depth

<?php 
    // https://wordpress.stackexchange.com/questions/124172/determine-term-depth 
    // //https://wordpress.stackexchange.com/questions/58814/get-second-level-terms-of-custom-taxonomy
?>

<?php 
    $whole_tax = get_terms(array('taxonomy' => 'szkolenia_kategorie', 'hide_empty' => false));
    $second_level = array_filter($whole_tax, function ($t) {
    // This term has a parent, but its parent does not.
    return $t->parent != 0 && get_term($t->parent, 'szkolenia_kategorie')->parent == 0;});
?>