I want to use the datepicker that gets bundled with WordPress on the front end of a website. I enqueued jquery-ui-datepicker
but the datepicker isn’t styled(no js error in console). Is there a corresponding wp_enqueue_style
for that?
I used this code in functions.php
function rr_scripts() {
wp_enqueue_script( 'jquery' );
wp_enqueue_script( 'jquery-ui-datepicker', array( 'jquery' ) );
wp_register_style( 'bootstrap_css', get_template_directory_uri() . '/assets/css/bootstrap.min.css' );
wp_enqueue_style( 'bootstrap_css' ); # I'm using Twitter Bootstrap as CSS(if it matters)
}
add_action( 'wp_enqueue_scripts', 'rr_scripts' );
As far as I know, there is not style for datepicker. You have to register your own. The code then will be:
To load script & style, add the following code to your theme’s
functions.php
file.Script for back-end use:
I have to hook into
options-general.php
to display on Settings->Date Picker. Just put this code again in functions.php file below previous code.Please see more details on Add a jQuery Date Picker to WordPress Theme or Plugin