Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save barryhughes/7e0342ffd7b91d7325a4ec588a4c2ed4 to your computer and use it in GitHub Desktop.
Save barryhughes/7e0342ffd7b91d7325a4ec588a4c2ed4 to your computer and use it in GitHub Desktop.
<?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