Drupal 7 - How to display the TID of a term reference field in a content type? I have a content type called video and a term reference field called category. I want to be able to output the TID of the term reference field in my content display. Is there a way to do this to expose the TID of the term? I'm able to generate a link from the term in the manage displayed settings, but it has an alias to it so it won't show the tid in the url.
The best way to do this is to make a new field formatter.  You need to implement two hooks, hook_field_formatter_info() and hook_field_formatter_view().  The info hook tells Drupal about your formatter and the view does the heavy lifting.  You can then use this on the Manage Display for the field in your content type.

The easiest way to do this is to clone them from taxnomy.module, and modify.  Something like this would be a start

/**
 * Implements hook_field_formatter_info().
 */
function MYMODULE_field_formatter_info() {
  return array(
    'MYMODULE_term_name_with_tid' =&gt; array(
      'label' =&gt; t('Term name + tid'),
      'field types' =&gt; array('taxonomy_term_reference'),
    ),
  );
}

function MYMODULE_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) {
  $element = array();

  switch ($display['type']) {
    case 'MYMODULE_term_name_with_tid':
      foreach ($items as $delta =&gt; $item) {
        $name = ($item['tid'] != 'autocreate' ? $item['taxonomy_term']-&gt;name  : $item['name']);
        $element[$delta] = array(
          '#markup' =&gt; check_plain($name) . '(' . $item['tid'] . ')',
        );
      }
      break;
  }

  return $element;
}