How to get taxonomy terms of a vocabulary in Drupal 8

Posted by admin on Tue, 12/26/2017 - 13:30

Quick but helpful example - how to get the taxonomy terms of a vocabulary?

$tree = \Drupal::entityTypeManager()->getStorage('taxonomy_term')->loadTree($vid, $parent = 0, $max_depth = NULL, $load_entities = FALSE);

Where $vid - vocabulary machine name
$parent - parent tid (0 is a default and top level
$max_depth - the maximum depth of the tree
$load_entities - whether load entities or not

×

Hey! Don't miss a new cool stuff!

Add new comment