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

what drugs shou... (not verified)

Where Can Buy Viagra Cheapest Price

is neurontin co... (not verified)

Il Cialis Funziona

cialis coupon (not verified)

Legally Provera Without Dr Approval

cialis coupon (not verified)

Legally Provera Without Dr Approval

gabapentin wiki (not verified)

Buy Kamagra Jelly

buy cialis 10mg (not verified)

Cialisonline4all Online Pharmacy Review

valtrex (not verified)

Acquistare Cialis Con Postepay

is generic viag... (not verified)

Il Cialis E Mutuabile

zithromax price (not verified)

Maradona Propecia

compare cialis ... (not verified)

Cialis Samples

viagra uk (not verified)

Amoxicillin Without Prescriptions

cost of propeci... (not verified)

Vendita Viagra Pisa

buy propecia in uk (not verified)

Cialis Comprar Precio

generic propeci... (not verified)

Priligy 30 Mg Vademecum

buy generic pro... (not verified)

Cephalexin Pain When Urinating

viagra user (not verified)

Cialis Ricetta Online

propecia medication (not verified)

Where To Order Finasteride

propecia generi... (not verified)

Cats On Amoxicillin

how long for pr... (not verified)

Kamagra Review

descargar kamag... (not verified)

pages jaunes levitra

kamagra 100mg r... (not verified)

Cephalexin Dosage Pneumonia