Created
October 31, 2016 21:00
-
-
Save andrasguseo/552c25143f0856341166acc4c72c5436 to your computer and use it in GitHub Desktop.
For Robert - Show only today's events in all views, when there is no filtering for date
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 | |
/* | |
* For the following plugins: | |
* The Events Calendar | |
* | |
* With this snippet you will only see today's events in any | |
* calendar view, if there is no date set in the filter bar. | |
* If there are no events, then "There were no results found." | |
* is shown. | |
* Add to your child theme's functions.php file | |
*/ | |
add_action( 'tribe_events_pre_get_posts', 'show_only_todays_events_first' ); | |
function show_only_todays_events_first( $query ) { | |
if ( empty( $_REQUEST['tribe-bar-date'] ) ) { | |
$today = date("Y-m-d"); | |
$query->set( 'start_date', $today ); | |
$query->set( 'end_date', $today ); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment