I have a content type with a taxonomy term. I can load the first EntityReferenceItem using


then I can tid doing ->target_id (and then manually load the Term object via Term::load.

But is there a function of EntityReferenceItem that I can call to get it to load the corresponding term? I'm thinking something like:


I don't see anything at the Drupal API reference

2 Answers 2


See http://wizzlern.nl/drupal/drupal-8-entity-cheat-sheet, where it lists the properties of common field types.

If you want to see the properties of a field type, one way to do that is by looking at the propertyDefinitions() method of the field type class, in this case EntityReferenceItem.

  • What is there multiple values allowed? ->country[0]->entity ?
    – Nic
    Commented May 5, 2016 at 14:12
  • not specifying a delta means [0],works always, also on multi-value fields. Delta works with [1] or ->get(1).
    – Berdir
    Commented May 5, 2016 at 14:42

Update code for 8.6, following example of term reference field

$tid = $para->get('field_category')->getString();
$tname = $para->get('field_category')

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.