Tos Web Developer provides insights, tutorials, and advice around topics including content strategy, design, Drupal Development, Drupal Custom Module Development, Drupal 8 Custom themes, PHP, Server, Twig, and more



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

| Designed And Blog Post by www.toswebdeveloper.com