php - Wordpress, get current level of taxonomy in an archive page -


i'm creating wordpress site display catalogue of items using custom post type , custom hierarchical taxonomy. i'd keep simple , deal items in single archive page, need how determine level of taxonomy displayed. basically, need following functionality:

if ($current_term_level = 0) {     // show first drop-down } else if ($current_term_level = 1) {     // show second drop-down } else {     // show third drop-down } 

can please explain how $current_term_level output appropriate values?

try get_ancestors() wp function :

function get_tax_level($id, $tax){     $ancestors = get_ancestors($id, $tax);     return count($ancestors)+1; }  $current_term_level = get_tax_level(get_queried_object()->term_id, get_queried_object()->taxonomy);  if ($current_term_level = 0) {     // show first drop-down } else if ($current_term_level = 1) {     // show second drop-down } else {     // show third drop-down } 

Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -