Created
April 26, 2017 14:19
-
-
Save barryhughes/ef00b62e9042d8f11deb1e95304739ae to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
/** | |
* 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