Last active
September 18, 2015 21:21
-
-
Save elimn/a378f3f807de8f701d86 to your computer and use it in GitHub Desktop.
MT | TEC | Prepend category name(s) to event title
This file contains hidden or 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 the event titles | |
function tribe_events_title_include_cat ($title, $id) { | |
$separator = ' » '; // 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); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment