6 April 2012

Load taxonomy term object by name or tid. Also how to get term parents from top to bottom.

Source code viewer
  1. // Case-insensitive and trimmed mapping for getting taxonomy term object by term name. In Drupal 5, 6, 7.
  2. taxonomy_get_term_by_name($name, $vocabulary = NULL);
  3.  
  4. // Return the term object matching a term ID. In Drupal 7+.
  5. taxonomy_term_load($tid)
  6.  
  7. // Get term parents from top to bottom.
  8. $terms = taxonomy_get_parents_all($tid);
  9. $terms = array_reverse($terms);
Programming Language: PHP