How to get the taxonomy terms list of a selectes vocabulary ?
Using entityQuery, you can get the taxonomy terms of a particular vocabulary.
   $query = \Drupal::entityQuery('taxonomy_term');
   $query->condition('vid', "tags");
   $tids = $query->execute();
   $terms = \Drupal\taxonomy\Entity\Term::loadMultiple($tids);
If you want to get several vocabulary, use OR condition like that. Â Â Â $query_or->condition('vid', "tags");
   $query_or->condition('vid', "test");
   $query->condition($query_or);
Get Taxonomy name
     $name = $term->toLink()->getText();
Create link to the term
     $link = \Drupal::l($term->toLink()->getText(), $term->toUrl());
NOTE : I don't know it is the best way, but it's working
Comments7
To sort by weight, we can…
To sort by weight, we can add
$query->sort('weight');
$tree = \Drupal:…
  $tree = \Drupal::entityTypeManager()->getStorage('taxonomy_term')->loadTree('tags', $parent = 0, $max_depth = NULL, $load_entities = FALSE);
Get Terms by taxonomy
$terms = \Drupal::service('entity_type.manager')->getStorage("taxonomy_term")->loadTree('nieuws_category', $parent = 0, $max_depth = NULL, $load_entities = FALSE);
How can we load terms from…
How can we load terms from multiple vocabulary using this storage.
print terms in twig file.
I have got the list of terms but i want to print these terms in my views block  twig file.
so how can i do that ?
Â
Using a viewbuilder.
\Drupal::entityTypeManager()->getViewBuilder('taxonomy_term')->viewMultiple($loaded_terms, 'taxonomy_teaser');
Get name & tid from loaded terms
foreach ($terms as $term) {
  $name = $term->get('name')->getString();
  $tid = $term->get('tid')->getString();
}