如何在wp管理员帖子类型中允许MultiDatesPicker?

时间:2018-04-24 作者:Poonam

WP自定义post类型已经使用了jquery UI日期选择器,但我需要为on字段添加多日期选择器。我已添加

function pw_loading_scripts_wrong() {
    echo \'<script src="https://cdn.rawgit.com/dubrox/Multiple-Dates-Picker-for-jQuery-UI/master/jquery-ui.multidatespicker.js">\';
}
add_action(\'admin_head\', \'pw_loading_scripts_wrong\');
以及

$(function() {
      $( ".datepicker").multiDatesPicker({
        minDate: 0, showButtonPanel: true, changeMonth: true, changeYear: true          
            , onSelect: function(dateText, inst) { inst.settings.defaultDate = dateText; }

      });
    });
但仍然不起作用。请帮忙。

1 个回复
SO网友:NikHiL Gadhiya
try now this code
<?php  function load_requirements() 
{
        wp_register_script(\'mdp\', \'https://cdn.rawgit.com/dubrox/Multiple-Dates-Picker-for-jQuery-UI/master/jquery-ui.multidatespicker.js\');
        wp_enqueue_script(\'mdp\');
}
add_action(\'admin_head\', \'load_requirements\');?>


 jQuery(document).ready(function($) 
 {
   $(\'.datepicker\').multiDatesPicker();
 });
结束