Adjusting how many years display in the calendar view dropdown

Published on: August 22, 2012 | Categories: Tutorial

Some folks prefer to control how many years frontend users can choose from on the dropdown that appears in calendar view. You can use the following code in your themes functions.php file to adjust how many years show in that dropdown:

/*-----------------------------------------------------------------------------------*/
/* filter the number of years to go back
/*-----------------------------------------------------------------------------------*/
add_filter('tribe_years_to_go_back', 'my_tribe_years_to_go_back');
function my_tribe_years_to_go_back() {
	return 10; //returns 2 years back from the current year
}
/*-----------------------------------------------------------------------------------*/
/* filter the number of years to go forwards
/*-----------------------------------------------------------------------------------*/
add_filter('tribe_years_to_go_forward', 'tribe_years_to_go_forward');
function tribe_years_to_go_forward() {
	return 3; //returns 3 years forward from the current year
}