Skip to content

Instantly share code, notes, and snippets.

@afragen
Created December 18, 2012 01:09
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 afragen/4324054 to your computer and use it in GitHub Desktop.
Save afragen/4324054 to your computer and use it in GitHub Desktop.
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.
// 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;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment