Show node parent terms

  1. <?php
  2. // split out taxonomy terms by parent
  3. function bowwowtheme_liquid_print_terms($nid) {
  4.   $terms = taxonomy_node_get_terms($nid);
  5.   $links = array();
  6.   $processed = array();
  7.   if($terms){
  8.     foreach($terms as $term){
  9.       $parents = taxonomy_get_parents_all($term->tid);
  10.       foreach($parents as $parent){
  11.         if(!in_array($parent->tid, $processed)){
  12.           $links[] = l($parent->name, taxonomy_term_path($parent), array('rel' => 'tag', 'title' => strip_tags($parent->description)));
  13.           $processed[] = $parent->tid;
  14.         }
  15.       }
  16.     }
  17.     $output = theme('item_list', $links);
  18.     return $output;
  19.   }
  20. }
  21. ?>