How to get taxonomy term depth or level in Drupal 7.
Source code viewer
$tid = 1; // your term id(tid) $limit = 99; $depth = 1; while($parent = db_query('SELECT parent FROM taxonomy_term_hierarchy WHERE tid = '.$tid)->fetchField()) { $depth++; $tid = $parent; if($depth > $limit) break; }Programming Language: PHP