1

How does one pull the value of a taxonomy term into the html.tpl.php file?

I know this needs to be done in the template.php file, no?

2

You should use the function template_preprocess_html in your theme.

For example.

function yourtheme_preprocess_html(&$vars){

// $tid - id of your taxonomy term
$term = taxonomy_term_load($tid);
$vars['head_title'] = $term->name;
}

Also, copy the html.tpl.php file to directory in your theme, where all the template files are located. And clear cache.

  • Thank you for the direction. I think I need to explain more. I populated a field on all nodes and all tax terms with a specific value pulled from a taxonomy list. The field name is the same on both nodes and tax terms. For example field_genre. How can I pull this value into the html.tpl.php file? – Baybook Dec 22 '16 at 12:27
  • You can install the Devel module for Drupal, then inside of the yourtheme_preprocess_html function watch the value of your field using a debug function, such as kpr($term) or another one. – Yakimkin Roman Dec 22 '16 at 12:40

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.