Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Remove past events from Revolution Slider slider. Event Espresso 4.
<?php
//* Please do NOT include the opening php tag, except of course if you're starting with a blank file
function tw_slider_revolution_exclude_expired_events( $query, $slider_id ) {
$post_type = isset($query['post_type']) ? $query['post_type'] : NULL;
if( $post_type == 'espresso_events' || in_array('espresso_events', $post_type) ) {
add_filter('posts_join', 'my_slider_posts_join', 10, 2);
add_filter('posts_where', 'my_slider_posts_where', 10, 2);
}
return $query;
}
add_filter( 'revslider_get_posts', 'tw_slider_revolution_exclude_expired_events', 10, 2 );
function my_slider_posts_join( $SQL, WP_Query $wp_query ) {
$SQL .= ' INNER JOIN ' . EEM_Datetime::instance()->table() . ' ON ( ' . EEM_Event::instance()->table() . '.ID = ' . EEM_Datetime::instance()->table() . '.' . EEM_Event::instance()->primary_key_name() . ' ) ';
remove_filter( current_filter(), __FUNCTION__ );
return $SQL;
}
function my_slider_posts_where( $SQL, WP_Query $wp_query ) {
$SQL .= ' AND ' . EEM_Datetime::instance()->table() . ".DTT_EVT_end > '" . current_time( 'mysql', true ) . "' ";
remove_filter( current_filter(), __FUNCTION__ );
return $SQL;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.