I want datepicker to who in a form in my wordpress template page, but it doesn't work.
This is the code I've the child theme functions.php:
function modify_jquery() {
if (!is_admin()) {
// comment out the next two lines to load the local copy of jQuery
wp_deregister_script('jquery');
wp_register_script('jquery', 'http://ajax.googleapis.com/ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js', false, '2.1.1');
wp_enqueue_script('jquery');
}
}
add_action('init', 'modify_jquery');
function load_jquery_ui_google_cdn() {
global $wp_scripts;
wp_enqueue_script('jquery-ui-core');
wp_enqueue_script('jquery-ui-slider');
// get the jquery ui object
$queryui = $wp_scripts->query('jquery-ui-core');
// load the jquery ui theme
$urlui = "https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.8/jquery-ui.min.js";
wp_enqueue_style('jquery-ui-smoothness', $urlui, false, null);
}
add_action('wp_enqueue_scripts', 'load_jquery_ui_google_cdn');
Then I've this in page-mypage.php:
<script>
$(function() {
$( "#datepicker" ).datepicker();
});
</script>
...other code...
Date: <input type="text" id="datepicker">
...other code...
</form>
But it doesn't show. Could you help me to wind what's wrong?