Drupal 8: Print term name from term id

Function to be used: taxonomy_term_load($term_id)
 

  $term_object = taxonomy_term_load($tid);  $term_name = $term_object->get('name')->value;
 
As mentioned, this is going to be a deprecated function very soon - so it's better to make usage of new Drupal approach, e.g:

$term_id = \Drupal\taxonomy\Entity\Term::load($tid)->get('tid')->value;$term_name = \Drupal\taxonomy\Entity\Term::load($tid)->get('name')->value;

Big thanks to this blog author

Latest blog

Web Analytics