6 April 2012

How to fix page titles for taxonomy term pages. It creates title from term hierarchy. You have to remove the views title override.

Source code viewer
  1. function THEME_preprocess_page(&$variables)
  2. {
  3. // Fix taxonomy view titles
  4. if(arg(0) == 'taxonomy' && arg(1) == 'term' && is_numeric(arg(2))) {
  5. $title = '';
  6.  
  7. $tree = taxonomy_get_parents_all(arg(2));
  8. $tree = array_reverse($tree);
  9.  
  10. foreach($tree as $term) {
  11. if(!empty($title)) $title .= ' » ';
  12. $title .= $term->name;
  13. }
  14.  
  15. drupal_set_title($title);
  16. }
  17. }
Programming Language: PHP