I have a views that include node title, a text field and a taxonomy term reference field.
I need to print the taxonomy term name via Global: PHP field (Views PHP) but I couldn't.
How to print taxonomy term name with Views PHP?
I can print the node title with that code:
Value Code:
return $row->title;
Output Code:
<?php print $value; ?>
or without Value Code:
Output Code:
<?php print $row->title; ?>
And I could print the taxonomy term ID with that code:
Output Code:
<?php print $data->field_field_my_taxonomy_term[0]['raw']['tid']; ?>
But using name or value instead of tid doesn't return anything.
I also tried to print the term name with these ones but unfortunately none of them worked:
$data->field_my_taxonomy_term[0]['raw']['value'];
(Above code prints nothing.)
<?php $data->field_my_taxonomy_term[0]['raw']['taxonomy_term']->name; ?>
(Above code prints nothing.)
So, I'm confused now and not know how to print taxonomy term name with Views PHP?
Note: I looked at these but still couldn't solve the problem: