Last active
October 20, 2017 17:13
-
-
Save joshfeck/ffb55bbe7bf123c72cfeac729cc99773 to your computer and use it in GitHub Desktop.
Remove past events from Revolution Slider slider. Event Espresso 4.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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