Created
March 21, 2018 22:33
-
-
Save barryhughes/51e192c60b86be32adb5630cdb8ece19 to your computer and use it in GitHub Desktop.
Remove events (from the upcoming events list) that have already started | TEC 4.6.x
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 | |
/** | |
* "Filter out" events that have already started from list view. | |
* | |
* This deviates from the default behaviour which will include events | |
* that started in the past but are ongoing (have not yet ended). | |
*/ | |
add_filter( 'posts_where', function( $sql, $query ) { | |
global $wpdb; | |
if ( 'list' !== $query->get( 'eventDisplay' ) ) { | |
return $sql; | |
} | |
$start_field = "{$wpdb->postmeta}.meta_value"; | |
$start_date = esc_sql( $query->get( 'start_date' ) ); | |
return "$sql AND $start_field > '$start_date' "; | |
}, 1000, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment