Custom layout for a field in Drupal 7 with using a term id and term name I have a content type that has term reference fields. One is a select one and one is a select many. What i'm trying to achieve is to overwrite the output for these fields. 

I want the output of these 2 fields to be &lt;a href="../?selectedArtist={artistID}"&gt;{artistName}&lt;/a&gt; and &lt;a href="../?selectedLocation={locationID}"&gt;{locationName}&lt;/a&gt;, &lt;a href="../?selectedLocation={locationID}"&gt;{locationName}&lt;/a&gt;

These links will point to a page with an isotope grid layout on it, and will prepopulate the filters with what is in the querystring. 

I have found how to update the output of the field, but I have no idea on how to get the terms ID and terms name. 

function TEMPLATENAME_preprocess_field(&amp;$variables) {
  if($variables['element']['#field_name'] == 'field_artist') {
      $variables['items']['0']['#markup'] = '&lt;a href="../?selectedArtist="&gt;View Map&lt;/a&gt;';
    }
  }
}


Thanks.
After looking at https://www.digett.com/insights/change-output-single-field-drupal-7-node I realised that you can use $variables['element']['#items']

term id
$variables['element']['#items']['0']['tid']

term name
$variables['element']['#items']['0']['taxonomy_term']-&gt;name