I'm trying to get Taxonomy data by particular node.
How can I get Taxonomy Term Id by using Node object ?
Drupal ver. 8.3.6Answer1:
If you want to get Taxonomy Term data you can use this code:
Hope it will be useful for you.
PS: If you need just Term's id you can use this:
You will get something like this:
[0 => ['target_id' => 23], 1 => ['target_id'] => 25]
In example my field has 2 referenced taxonomy terms. Thanks!Answer2:
You could do something like that:
$termId = $node->get('field_yourfield')->target_id;
Then you can load the term with
Hope this helps.