Powered by Blogger.

get drupal taxonomy term list using vocabulary


get drupal taxonomy term list using vocabulary

Get Drupal 7 taxonomy term list using the vocabulary machine name

function get_taxonomy_terms_by_vocabulary($vocabulary_machine_name){

$term_data = array();
$vid = taxonomy_vocabulary_machine_name_load($vocabulary_machine_name)->vid;
$terms = taxonomy_get_tree($vid);

//If you want to get more custom fields value, than use
//$terms = entity_load('taxonomy_term', FALSE, array('vid' => $vid));

foreach($terms as $term){
$term_data[$term->tid] = $term->name;
}

return $term_data;
}

No comments