Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Filter expired The Events Calendar events from a Geo Mashup map
/*
* Exclude expired events from Geo Mashup queries
*/
function calant_filter_geo_mashup_locations_fields( $fields ) {
global $spEvents;
if ( isset( $spEvents ) )
$fields .= ', eventEnd.meta_value as EventEndDate ';
return $fields;
}
add_filter('geo_mashup_locations_fields', 'calant_filter_geo_mashup_locations_fields');
function calant_filter_geo_mashup_locations_join( $join ) {
global $wpdb, $spEvents;
if ( isset( $spEvents ) )
$join .= " LEFT JOIN {$wpdb->postmeta} as eventEnd ON( o.ID = eventEnd.post_id ) ";
return $join;
}
add_filter('geo_mashup_locations_join', 'calant_filter_geo_mashup_locations_join' );
function calant_filter_geo_mashup_locations_where( $where ) {
global $spEvents;
if ( isset( $spEvents ) ) {
$today = date_i18n( The_Events_Calendar::DBDATETIMEFORMAT );
$where .= ' AND eventEnd.meta_key = "_EventEndDate" AND eventEnd.meta_value > "' . $today . '" ';
}
return $where;
}
add_filter('geo_mashup_locations_where', 'calant_filter_geo_mashup_locations_where' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment