Skip to content

Instantly share code, notes, and snippets.

@cyberhobo
Created July 25, 2012 16:55
Show Gist options
  • Save cyberhobo/3177241 to your computer and use it in GitHub Desktop.
Save cyberhobo/3177241 to your computer and use it in GitHub Desktop.
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