Use jquery datepicker in wordpress

后端 未结 2 870
情话喂你
情话喂你 2021-02-13 04:28

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 mo         


        
2条回答
  •  你的背包
    2021-02-13 05:05

    For loading bellows script & style add bellows code on theme functions.php file.

    Script for front-end 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 back-end 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 also funtions.php file or bellow those 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() { ?>
    
        

    After adding this code, you’ll got a date picker on Admin Menu->Settigns->Date Picker.

    Please see details on Add a jQuery DatePicker to WordPress Theme or Plugin

提交回复
热议问题