Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<?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
You can’t perform that action at this time.