Get all terms from the vocabulary

To get all terms from the specific vocabulary use below snippets

$vid = 'name_of_vocabulary';
$terms =\Drupal::entityTypeManager()->getStorage('taxonomy_term')->loadTree($vid);
foreach ($terms as $term) {
 $term_data[] = array(
  "id" => $term->tid,
  "name" => $term->name
 );
}

Comments