Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › datepicker year range for dropdown › Reply To: datepicker year range for dropdown
August 4, 2021 at 11:33 am
#34162
Keymaster
Hi,
Interesting question. I googled a bit around the datepicker script, and there is actually a way to extend the range. I constructed a custom script, which should hopefully resolve this – by adding +-100 years to the range on the page load.
add_action('wp_footer', 'wp_footer_datepicker_range_fix', 9999);
function wp_footer_datepicker_range_fix() {
?>
<script>
(function($){
setTimeout(function(){
$('.asp_datepicker.hasDatepicker').datepicker('option', 'yearRange', '-100:+100')
}, 500);
})(jQuery);
</script>
<?php
}
Try adding this code to the functions.php file in your theme/child theme directory – make sure to have a full server back-up first for safety. For more details you can check the safe coding guidelines.