Skip to content

Instantly share code, notes, and snippets.

@theeventscalendar
Forked from elimn/functions.php
Created September 18, 2015 21:21
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save theeventscalendar/ebf2adea40d4ba96a01f to your computer and use it in GitHub Desktop.
Save theeventscalendar/ebf2adea40d4ba96a01f to your computer and use it in GitHub Desktop.
Add category name(s) to event title
<?php
// Prepends category name(s) to the event titles
function tribe_events_title_include_cat ($title, $id) {
$separator = ' &raquo; '; // HTML Separator between categories and title
$cats = get_the_terms($id, 'tribe_events_cat');
$is_ajax = defined('DOING_AJAX') && DOING_AJAX;
$is_truly_admin = is_admin() && !$is_ajax;
if (tribe_is_event($id) && $cats && !is_single() && !$is_truly_admin) {
$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);
@robograce
Copy link

Where would you put this in the plug in directory?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment