Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save barryhughes/ef00b62e9042d8f11deb1e95304739ae to your computer and use it in GitHub Desktop.
Save barryhughes/ef00b62e9042d8f11deb1e95304739ae to your computer and use it in GitHub Desktop.
<?php
/**
* Alter list view queries to be accurate to the minute (vs accurate to the second)
* to give additional opportunities for persistent caching to kick in.
*/
add_action( 'tribe_events_pre_get_posts', function( $event_query ) {
// Only modify event list queries
if ( 'list' !== $event_query->get( 'eventDisplay') ) {
return;
}
// Modify start date to always use 00 seconds
$start_date = $event_query->get( 'start_date' );
$start_date = preg_replace( '/^(\d{4}-\d{2}-\d{2} \d{2}:\d{2}:)(\d{2})$/', '${1}00', $start_date );
$event_query->set( 'start_date', $start_date );
} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment