public
Last active

The Events Calendar Category Colors: place this code in your theme's functions.php file if you see the calendar taking on the styling of the first event of the month. If it causes problems. Don't use it.

  • Download Gist
remove_tribe_cat_once.php
PHP
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
// Try to stop the first event category from being added to the article classes
// (when the default page template is used) - Thanks Barry
add_filter('post_class', 'remove_tribe_cat_once', 1);
 
function remove_tribe_cat_once(array $classes) {
if ( class_exists('TribeEvents') ) {
// The Main Calendar Page or Calendar Category Page
if (( tribe_is_month() && !is_tax() ) || ( tribe_is_month() && is_tax() )) {
static $count = 0;
if ($count++ === 0) {
remove_filter('post_class', array(TribeEvents::instance(), 'post_class'));
}
else {
add_filter('post_class', array(TribeEvents::instance(), 'post_class'));
remove_filter('post_class', 'remove_tribe_cat_once');
}
return $classes;
}
}
}

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.