Add class to term-reference output I'm trying to add a simple class to a link outputted via print render($content['field_tags']). I'm using the Bootstrap theme. These are the approaches I've tried so far:


Hooking into template_preprocess_node - no luck here as the html isn't generated yet.
Hooking into template_field - this contains exactly what I expect but the links being generated don't obey the classes set here.
Hacking node.tpl.php and manually outputting the terms - this sort of works but it's not the best solution.


This is the output as it is at the moment:

&lt;a href="/tags/drupal" typeof="skos:Concept" property="rdfs:label skos:prefLabel" datatype=""&gt;drupal&lt;/a&gt;


I don't want to add any more modules as there has to be a code solution to this, I'm not sure what I'm missing here. How do I add a class to link outputted in field_tags?
One option would be to preprocess the field:

function MYTHEME_preprocess_field(&amp;$vars) {
  if ($vars['element']['#field_name'] == 'field_tags') {
    array_walk($vars['items'], function(&amp;$el) { $el['#options']['attributes']['class'][] = 'some-class'; } );
  }
}