0

I'm not a PHP developer, so I have a problem with customizing a theme.

I create a vocabulary "City" and a term "Shiraz", then a field "field_city" as a taxonomy term in my content type.

Now I want to print this field, so in the tpl file I write the following code:

<?php print render($content['field_city']); ?>

but nothing happens. What am I missing?

1

Try this out :

  1. Make sure you set the right display of the field, like the following picture.enter image description here

  2. loop through Items and render vocab fields.

<?php foreach ($content['field_city']['#items'] as $item): ?>
   <?php print render($item['taxonomy_term']->name); ?>
<?php endforeach; ?>

Note : print only name field, if you have another fields in your vocabulary add them, like $item['taxonomy_term']->some_field

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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