Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Removes upcoming events via custom query for the [ESPRESSO_EVENTS] shortcode
<?php
//* Please do NOT include the opening php tag, except of course if you're starting with a blank file
// change the page slug on line 10 to match your past events page slug
add_action('pre_get_posts','my_remove_upcoming_ee_events', 10);
function my_remove_upcoming_ee_events($wp_query){
if (has_filter( 'FHEE__EEH_Event_Query__apply_query_filters' )
&&
is_page('past-events-page')
){
add_filter('posts_where', 'my_custom_ee_posts_where', 11, 2);
}
};
function my_custom_ee_posts_where( $sql ) {
$sql = ' AND '
. EEM_Datetime::instance()->table()
. '.DTT_EVT_start < \''
. current_time('mysql', true)
. '\' ';
remove_filter('posts_where', 'my_custom_ee_posts_where', 11);
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.