Drupal 8: Print term name from term id

English

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;

Add new comment

Restricted HTML

  • Allowed HTML tags: <a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type> <li> <dl> <dt> <dd> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id>
  • Lines and paragraphs break automatically.
  • Web page addresses and email addresses turn into links automatically.