Created
March 2, 2017 23:58
-
-
Save geoffgraham/87183e154af9efdbaa36c9ea2858698b to your computer and use it in GitHub Desktop.
The Events Calendar 4.4.3 // Prepend category name to event title
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Prepends category name(s) to to event titles | |
function tribe_events_title_include_cat ($title, $id) { | |
$separator = ' » '; // 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