This website uses cookies to personalize your experience. By using this website you agree to our cookie policy.

Reply To: Limiting date filter year

#55341
Ernest MarcinkoErnest Marcinko
Keymaster

It’s definitely possible to resolve, I think I just made a mistake in the code, please try this one instead:

add_action(
	'wp_footer',
	function () {
		?>
		<script>
			window.addEventListener("load", () => {
				const loadYears = ()=> {
					setTimeout(function(){
						jQuery('.asp_w .hasDatepicker').datepicker('option', 'yearRange', '-9:+1')
					}, 500);
				};
				document.querySelectorAll(".asp_main_container").forEach((el) => {
					el.addEventListener("asp_settings_show", (event) => {
						loadYears();
					});
				});
				loadYears();
			});
		</script>
		<?php
	}
);

I used a jQuery shorthand $ in the previous code which didn’t work. This should be the one.