Description

If you use a Mini Calendar Widget on your site then on the first-page load it will show you the number of events from the month that you set up in the back-end. If you set up 5 events and there are less than that on the current day, it will show you events from the coming days as well.

If you click on a specific date in the calendar, then you will only see the events for that day.

If you would like to show only today’s events on the first-page load as well, then the below snippet will help you.

Usage

Copy the below code into your (child) theme’s functions.php file (or wherever you usually put custom code).

Plugins

  • The Events Calendar
  • Events Calendar PRO

Snippet

add_action( 'pre_get_posts', 'tribe_andras_custom_mini_calendar_starting_query' );

function tribe_andras_custom_mini_calendar_starting_query( $query ) {

	$is_widget = $query->get( 'is_tribe_widget' );
	$event_display = $query->get( 'eventDisplay' );

	if ( $is_widget && $event_display == 'custom' ) {
		$query->set( 'eventDisplay', 'day' );
	}
}

Notes

  • Originally written in April 2019
  • Tested with The Events Calendar 4.8.2  and Events Calendar PRO 4.6.2.1
  • Author: András Guseo

Disclaimer

As with all of our recipes, please note that we share this in the hope it will be useful but without any guarantees or commitments. If you wish to use it, it is your responsibility to test it first of all and adapt it to your needs (or find someone who can do so on your behalf). We are unable to provide further support in relation to this recipe.