Skip to content

Instantly share code, notes, and snippets.

@andrasguseo
Created October 31, 2016 21:00
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 andrasguseo/552c25143f0856341166acc4c72c5436 to your computer and use it in GitHub Desktop.
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
<?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