Thread Starter
fl0ri
(@fl0ri)
Anyone? I still have no idea how to solve this since The Events Calendar does not work with categories in terms of upcoming and past, but with the field EventDisplay, which I cannot handle. So if you happen to have an idea on how to add a body class “past-event” to the single view of past events, please let me know.
Thread Starter
fl0ri
(@fl0ri)
I did find an approach to solve this here:
https://theeventscalendar.com/support/forums/topic/displaying-a-class-name-for-past-events-only/
Unfortunately it’s not working (any more?).
Also I would like to extend the function as follows:
/* Adds new body class for past event */
add_filter( 'body_class', 'tribe_events_past_events_body_class' );
function tribe_events_past_events_body_class( $classes ) {
global $wp_query;
$event_date = get_query_var( 'eventDate' );
if ( isset( $event_date ) ) {
$this_month = current_time( 'Y-m' );
$is_past = strtotime( $event_date ) < strtotime( $this_month );
if ( $is_past ) {
$classes[] = 'tribe-is-past';
}
else {
$classes[] = 'tribe-is-upcoming';
}
}
return $classes;
}
But in any case, neither the original code from the forum nor the modified one work.
Does someone have an idea?
I managed to put something together that adds a class to the body if the event has passed.
Here’s a Gist of it:
Add body class “past-event” to single event view
I hope that helps
Thread Starter
fl0ri
(@fl0ri)
Sean! Thank you! This really is working. Great job!
Hey Sean,
Thanks for helping out once again 🙂
We really appreciate it!
Best,
Nico