Skip to content

Instantly share code, notes, and snippets.

@stephenharris
Last active December 15, 2015 05:08
Show Gist options
  • Save stephenharris/5206343 to your computer and use it in GitHub Desktop.
Save stephenharris/5206343 to your computer and use it in GitHub Desktop.
A function which adds classes to event pages corresponding to the event
<?php
/**
* A function which adds classes to event pages corresponding to the event
* E.g. adds 'eo-event-cat-[cat slug]' class for each category the event belongs to.
* Adds 'eo-event-venue-[venue slug]' if the event has a venue
* Adds time based class: eo-event-future/past/running for future/past/running events
*
* @url http://wordpress.org/support/topic/problem-with-highlight-in-menu-change-url-of-events?replies=8#post-3458829
* Not tested
*/
add_filter( 'body_class', 'my_event_organiser_add_classes_to_event_body');
function my_event_organiser_add_classes_to_event_body($classes){
if( !is_singular( 'event' ) )
return $classes;
$event_classes = eo_get_event_classes( get_the_ID() );
return array_merge( $classes, $event_classes );
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment