logo

Programmatically get term list by Vocabulary in Drupal 8

13
August

Programmatically get term list by Vocabulary in Drupal 8
By: Anonymous | Published On: Sat, 08/13/2022 - 20:37

	$vid = 'Vocabulary machine name';	// Vocabulary machine name for example city, state etc. 
	$terms =\Drupal::entityTypeManager()->getStorage('taxonomy_term')->loadTree($vid);
	foreach ($terms as $term) {
	 $termlist[$term->tid] = $term->name;
	}

Need Help ?