Home › Forums › Backend Issues (wp-admin) › Get years below 1917 to show on date field select box › Reply To: Get years below 1917 to show on date field select box
Use the appropriate hook
functions.php
function my_admin_enqueue_scripts() {
wp_enqueue_script( 'date-picker-js', get_template_directory_uri() . '/js/custom_date_picker.js', array(), '1.0.0', true );
}
add_action('admin_enqueue_scripts', 'my_admin_enqueue_scripts');
custom_date_picker.js
// function to merge two Javavascipt objects IE compatible, from prototype.js http://prototypejs.org/doc/latest/language/Object/extend/
function extend(destination, source) {
for (var property in source)
destination[property] = source[property];
return destination;
}
// Acf hook -> Hooks -> Filters -> date_picker_args
// see https://www.advancedcustomfields.com/resources/adding-custom-javascript-fields/
acf.add_filter('date_picker_args', function( args, $field ){
// do something to args
var custom_args = {
yearRange: "-200:+100", // value to change
};
args = extend(args, custom_args)
// return
return args;
});
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.