Search code examples
drupal-7drupal-taxonomy

How to render custom field taxonomy on Drupal 7?


I've created some custom field in my taxonomy vocabulary called Categories: - fotogallery (multiple files) - incipit (plain text) - ...

But I don't know how to render them.

I've tried field_view_field but it refers just to entity. I've tried render and drupal_render also.

Actually I'm accessing directly to $term->field_incipt['und'][0]['safe_value'] property, that I konw it's not recommended.

Any ideas?


Solution

  • Taxonomy terms in Drupal 7 are entities, and as such you can use field_view_field()to safely get the render array:

    $view = field_view_field('taxonomy_term', $term, 'field_incipt'); 
    print render($view);