taxonomy_get_parents_all

Definition

taxonomy_get_parents_all($tid)
modules/taxonomy.module, line 554

Description

Find all ancestors of a given term ID.

Code

<?php
function taxonomy_get_parents_all($tid) {
  $parents = array();
  if ($tid) {
    $parents[] = taxonomy_get_term($tid);
    $n = 0;
    while ($parent = taxonomy_get_parents($parents[$n]->tid)) {
      $parents = array_merge($parents, $parent);
      $n++;
    }
  }
  return $parents;
}
?>
 
 

Drupal is a registered trademark of Dries Buytaert.