How to load taxonomy term by name in Drupal 8

Posted by admin on Fri, 01/19/2018 - 14:57

Code snippet to load taxonomy term by name (or any otehr property) in Drupal 8.

$term_name = 'Your Term Name';
$term = \Drupal::entityTypeManager()
      ->getStorage('taxonomy_term')
      ->loadByProperties(['name' => $term_name]);

If you want to use vid and name - just add that to properties array like this:

$term_name = 'Your Term Name';
$vid = 3;
$term = \Drupal::entityTypeManager()
      ->getStorage('taxonomy_term')
      ->loadByProperties(['name' => $term_name, 'vid' => $vid]);
×

Hey! Don't miss a new cool stuff!

Comments

VincentBifiP (not verified)
FrankSkync (not verified)
FrankSkync (not verified)
FrankSkync (not verified)
VincentBifiP (not verified)
FrankSkync (not verified)
JamesDer (not verified)
StevVise (not verified)

Ialis Sans Ordonnance En Belgique http://cialisir.com - Cialis Meds From Canada Without Rx Cialis Cialis Generique Prix

StevVise (not verified)

Prix Du Viagra Au Quebec http://buycialisuss.com - buy cialis Colcrys 0.6 Mg Tablet cialis 5mg best price Cialis 14 Compresse Prezzo

StevVise (not verified)

Prix Du Viagra Au Quebec http://buycialisuss.com - buy cialis Colcrys 0.6 Mg Tablet cialis 5mg best price Cialis 14 Compresse Prezzo

StevVise (not verified)

Prix Du Viagra Au Quebec http://buycialisuss.com - buy cialis Colcrys 0.6 Mg Tablet cialis 5mg best price Cialis 14 Compresse Prezzo

Add new comment