0

What would be the best way to render the Taxonomy Vocabulary Term description value? I can render the term id and label/title, but the description seems to need something else that I'm not quite getting.

  // Render ID - working
  $termID = \Drupal::entityTypeManager()->getStorage('taxonomy_term')->load(419)->id();
  
  // Render Label/Title - working
  $termLabel = \Drupal::entityTypeManager()->getStorage('taxonomy_term')->load(419)->label();
  
  // Not sure how to get the description of the taxonomy term - not working
  $termDescription = \Drupal::entityTypeManager()->getStorage('taxonomy_term')->load(419)->description();
1
  • In future when you report something is not working, it helps to include information about what occurs.
    – cilefen
    Oct 11, 2022 at 22:18

1 Answer 1

1

The correct method is getDescription.

2
  • This is what I tried also and this doesn't provide a value. Is there an alternate way of writing this that would use getDescription instead? $termDescription = \Drupal::entityTypeManager()->getStorage('taxonomy_term')->load(419)->getDescription();
    – user108983
    Oct 12, 2022 at 1:55
  • Nevermind.. I'm an idiot. getDescription worked great!
    – user108983
    Oct 12, 2022 at 3:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.