Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save geoffgraham/87183e154af9efdbaa36c9ea2858698b to your computer and use it in GitHub Desktop.
Save geoffgraham/87183e154af9efdbaa36c9ea2858698b to your computer and use it in GitHub Desktop.
The Events Calendar 4.4.3 // Prepend category name to event title
<?php
// Prepends category name(s) to to event titles
function tribe_events_title_include_cat ($title, $id) {
$separator = ' &raquo; '; // Separator between categories and title
$cats = get_the_terms($id, 'tribe_events_cat');
if (tribe_is_event($id) && $cats && !is_single()) {
$cat_titles = array();
foreach($cats as $i) {
$cat_titles[] = $i->name;
}
$title = implode(', ', $cat_titles) . $separator . $title;
}
return $title;
}
add_filter('the_title', 'tribe_events_title_include_cat', 100, 2);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment