0

I would like to bring in terms (just parents) from one taxonomy vocabulary to use as options in a form but I can't seem to pull them in. I thought taxonomy_vocabulary_machine_name_load would work but I can't seem to get the terms to show up.

  $topic_options = array();
  $name = 'web_topics';
  $myvoc = taxonomy_vocabulary_machine_name_load() as $name => $vocabulary;
  $tree = taxonomy_get_tree($myvoc->vid);
  foreach ($tree as $term) {
    $topic_options[$name] = $vocabulary->name;
  } 
3
  • I tried and it also didn't work. ` $vocabulary = taxonomy_vocabulary_machine_name_load('unite_web_topic'); $terms = taxonomy_get_tree($vocabulary->vid); $topic_options = array(); foreach($terms as $term) { $courses[$term->tid] = $term->name; }`
    – kmharrell
    Commented Oct 5, 2020 at 23:29
  • Should be $topic_options[$term->tid] = $term->name;
    – No Sssweat
    Commented Oct 5, 2020 at 23:36
  • Thanks so much!
    – kmharrell
    Commented Oct 5, 2020 at 23:44

0

Browse other questions tagged or ask your own question.