Created
May 24, 2019 23:41
-
-
Save jentheo/917cba0349f09fa232f4587ae6c043d8 to your computer and use it in GitHub Desktop.
Change start date for events on the main events page
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
* | |
* Set the default date for views like List and Month | |
* Modify the $date variable below to set your date | |
*/ | |
function tribe_set_default_date( $wp_query ) { | |
// Only run on main event queries | |
if ( ! tribe_is_event_query() || ! $wp_query->is_main_query() || $wp_query->get( 'eventDate' ) != '') return; | |
// Set this to the date you want shown, in YYYY-MM-DD format | |
$date = '2009-01-01'; | |
// Select which TEC views you want this to apply to by uncommenting them | |
if ( | |
tribe_is_list_view() | |
// || tribe_is_map() | |
// || tribe_is_photo() | |
// || tribe_is_month() | |
// || tribe_is_week() | |
// || tribe_is_day() | |
) { | |
$wp_query->set( 'eventDate', $date ); | |
} | |
} | |
if ( function_exists('tribe_is_event_query') ) { | |
add_action( 'parse_query', 'tribe_set_default_date', 100); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment