Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/242.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 日期选择器在wordpress中不工作_Php_Wordpress_Jquery Ui - Fatal编程技术网

Php 日期选择器在wordpress中不工作

Php 日期选择器在wordpress中不工作,php,wordpress,jquery-ui,Php,Wordpress,Jquery Ui,我正在尝试使用datepicker jquery ui添加一个自定义帖子字段。在function.php中,我有以下代码: function daily_idea_admin_script_style( $hook ) { global $post_type, $wp_scripts; if ( ( 'post.php' == $hook || 'post-new.php' == $hook ) && ( 'daily_idea' == $post_type ) ) {

我正在尝试使用datepicker jquery ui添加一个自定义帖子字段。在function.php中,我有以下代码:

function daily_idea_admin_script_style( $hook ) {
global $post_type, $wp_scripts;
if ( ( 'post.php' == $hook || 'post-new.php' == $hook ) && ( 'daily_idea' == $post_type ) ) {
    $ui = $wp_scripts->query('jquery-ui-core');
    if ($ui) {
        $uiBase = "http://ajax.googleapis.com/ajax/libs/jqueryui/{$ui->ver}/themes/cupertino";
        wp_enqueue_script('daily_idea', get_template_directory_uri() .'/js/daily_idea_script.js', array( 'jquery', 'jquery-ui-datepicker' ), '1.0', true);
        wp_enqueue_style('jquery-ui-min', "$uiBase/jquery-ui.min.css", FALSE, $ui->ver);
    }
  }
}

add_action( 'admin_enqueue_scripts', 'daily_idea_admin_script_style' );
信息元框与输入字段一起显示,但当我单击它时,日期选择器不显示

注意:这是我的第一个这是我在wordpress上创建的第一个自定义帖子域

编辑:我的自定义每日_idea_script.js是:

(function( $ ) {
$.noConflict();
$( '#daily_idea_date' ).datepicker({
    dateFormat: 'dd MM yy',
    onClose: function( selectedDate ){
        $( '#daily_idea_date' ).datepicker( 'option', 'maxDate', selectedDate );
    }
});

})(jQuery)

这里有几个错误

除去

$.noConflict(); // not neccessary
删除:

onClose: function( selectedDate ){
    $( '#daily_idea_date' ).datepicker( 'option', 'maxDate', selectedDate );
}
我猜您正在尝试设置日期选择器的最大日期,但您正在尝试在同一元素上重新创建日期选择器?你到底想在这里做什么

Datepicker与jQuery(document).ready()或$(function(){}的配合更为简洁。使用的方法,函数将立即运行,此时dom尚未就绪,jQuery无法找到标识的元素