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

Reply To: Limiting date filter year

#55327
Ernest MarcinkoErnest Marcinko
Keymaster

You are welcome!

I suspect it’s because on mobile it needs to be opened and the loading is delayed so the code does nothing. I think it’s still doable with a few changes:

add_action(
	'wp_footer',
	function () {
		?>
		<script>
			window.addEventListener("load", () => {
				const loadYears = ()=> {
					setTimeout(function(){
						$('.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
	}
);