Since taxonomy term is an entity all the Terms for a specific vocabulary can be fetched using following entity query.
$query = \Drupal::entityQuery('taxonomy_term')->condition('vid', 'YOUR_VOCABULARY');
$result = $query->execute();
foreach ($result as $key => $value) {
$result[$key] = Term::load($value)->getName();
}
$result can used for getting key value array of TID and Term Name.
No comments:
Post a Comment