Last active
July 16, 2019 18:42
-
-
Save barryhughes/7e0342ffd7b91d7325a4ec588a4c2ed4 to your computer and use it in GitHub Desktop.
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 | |
/** | |
* Hide 'expired' events from the /all/ recurring events view. | |
* | |
* This snippet is best added to a custom (mu-)plugin, for instance: | |
* | |
* wp-content/mu-plugins/ecp-customizations.php | |
* | |
* It is only intended as a temporary shim until a future version | |
* of The Events Calendar or Events Calendar PRO resolves things; | |
* it may or may not play nicely with other customizations. Use at | |
* own risk! | |
*/ | |
add_action( 'tribe_events_pro_pre_get_posts_recurrence', function() { | |
add_action( 'pre_get_posts', function( WP_Query $query ) { | |
static $once = 0; | |
if ( ! $query->is_main_query() || ! tribe_is_showing_all() || $once++ ) { | |
return; | |
} | |
$meta_query = (array) $query->get( 'meta_query' ); | |
$meta_query[] = [ | |
'key' => '_EventStartDate', | |
'value' => date_i18n( 'Y-m-d H:i:s' ), | |
'compare' => '>=' | |
]; | |
$query->set( 'meta_query', $meta_query ); | |
}, 1000 ); | |
} ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment