drupal 8 get taxonomy term value in node

后端 未结 6 959
既然无缘
既然无缘 2021-02-08 05:36

Drupal\\node\\Entity\\Node Object ( [in_preview] => [values:protected] => Array ( [vid] => Array ( [x-default] =

6条回答
  •  误落风尘
    2021-02-08 06:23

    The following code will get you the term object you need.

    $term = Term::load($node->get('field_destination')->target_id);
    

    If you need the name of that term you can do the following

    $name = $term->getName();
    

    Hope this helps out!

提交回复
热议问题