sanchahous
sanchahous

Reputation: 181

Wordpress with datepicker

Here myrussiaonline

on my website you can see form under top slider. There are first input with id datepicker. So i need to call datepicker here in this input, but it's not working. In functions php included:

    <?php
wp_enqueue_script('jquery-ui-datepicker');
wp_enqueue_style('jquery-style', 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.2/themes/smoothness/jquery-ui.css');
?>

In footer:

    jQuery(document).ready(function() {
    jQuery('#datepicker').datepicker({
        dateFormat : 'dd-mm-yy'
    });
});

my input:

<input id="datepicker" style="height:15px;border:0; border-radius:0; width: 90px; position:relative;left: 50px; top: 31px; background: #E8E8E8; color: black;" type="text" name="datepicker" value="" class="hasDatepicker">

Also i checked ui core and css files and also datepicker.min.js loaded on my website, but I don't have reaction from my input. It's still ignoring date picking. So what's I do wrong?

Upvotes: 0

Views: 280

Answers (1)

user2439481
user2439481

Reputation:

I think you need to add script in action wp_enqueue_scripts. Please refer below code:

function my_theme_script(){
    wp_enqueue_script('jquery-ui-datepicker');
    wp_enqueue_style('jquery-style', 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.2/themes/smoothness/jquery-ui.css');
}    
add_action( 'wp_enqueue_scripts', 'my_theme_script');

Upvotes: 1

Related Questions