To load the script bellows and style, add the bellows code to the theme's functions.php file.
Script for external use
function add_e2_date_picker(){ //jQuery UI date picker file wp_enqueue_script('jquery-ui-datepicker'); //jQuery UI theme css file wp_enqueue_style('e2b-admin-ui-css','http://ajax.googleapis.com/ajax/libs/jqueryui/1.9.0/themes/base/jquery-ui.css',false,"1.9.0",false); } add_action('wp_enqueue_scripts', 'add_e2_date_picker');
Script for background use
function add_e2_date_picker(){ //jQuery UI date picker file wp_enqueue_script('jquery-ui-datepicker'); //jQuery UI theme css file wp_enqueue_style('e2b-admin-ui-css','http://ajax.googleapis.com/ajax/libs/jqueryui/1.9.0/themes/base/jquery-ui.css',false,"1.9.0",false); } add_action('admin_enqueue_scripts', 'add_e2_date_picker');
Just put this code in the funtions.php file or below this code.
function register_datepiker_submenu() { add_submenu_page( 'options-general.php', 'Date Picker', 'Date Picker', 'manage_options', 'date-picker', 'datepiker_submenu_callback' ); } function datepiker_submenu_callback() { ?> <div class="wrap"> <input type="text" class="datepicker" name="datepicker" value=""/> </div> <script> jQuery(function() { jQuery( ".datepicker" ).datepicker({ dateFormat : "dd-mm-yy" }); }); </script> <?php } add_action('admin_menu', 'register_datepiker_submenu'); ?>
After adding this code, you will have the opportunity to select a date in the Admin Menu-> Settigns-> Date Picker .
For more, see Add jQuery DatePicker to a WordPress Theme or Plugin.
source share