Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/11.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
Javascript 排队样式和脚本WordPress不起作用_Javascript_Wordpress_Enqueue - Fatal编程技术网

Javascript 排队样式和脚本WordPress不起作用

Javascript 排队样式和脚本WordPress不起作用,javascript,wordpress,enqueue,Javascript,Wordpress,Enqueue,我正在尝试将javascript和css放入WordPress中。我已经写了下面的代码,但它不工作,没有样式或css被添加到我的主题中 function add_theme_scripts() { wp_enqueue_style( 'cssdatepicker', get_template_directory_uri() . '/css/persian-datepicker.css', array(), '1.1', 'all'); wp_enqueue_script( 'jsda

我正在尝试将javascript和css放入WordPress中。我已经写了下面的代码,但它不工作,没有样式或css被添加到我的主题中

function add_theme_scripts() {

  wp_enqueue_style( 'cssdatepicker', get_template_directory_uri() . '/css/persian-datepicker.css', array(), '1.1', 'all');

  wp_enqueue_script( 'jsdate', get_template_directory_uri() . '/js/persian-date.js', array ( 'jquery' ), '1.1', true);
   wp_enqueue_script( 'jsdatepicker', get_template_directory_uri() . '/js/persian-datepicker.js', array ( 'jquery' ), '1.1', true);

}
add_action( 'wp_enqueue_scripts', 'add_theme_scripts' );

我想它会被添加,但它会显示缓存版本CSS和js,这可能是空白的

function add_theme_scripts() {

  wp_enqueue_style( 'cssdatepicker', get_template_directory_uri(). '/css/persian-datepicker.css', array(), null, 'all');

  wp_enqueue_script( 'jsdate', get_template_directory_uri() . '/js/persian-date.js', array ( 'jquery' ), null, true);
   wp_enqueue_script( 'jsdatepicker', get_template_directory_uri() . '/js/persian-datepicker.js', array ( 'jquery' ), null, true);

}
add_action( 'wp_enqueue_scripts', 'add_theme_scripts' );
使用此代码以非缓存方式运行更新的js和CSS文件

或 它已添加到您的站点,但路径错误,因此它将在控制台中抛出错误

您可以使用F12键在控制台中查看

请检查并让我知道您的状态

或 wp|u enqueue|脚本字符串$handle,字符串$src=,数组$deps=array,字符串| bool | null$ver=false,bool$in|u footer=false

如果您的$handle已经与其他样式或脚本一起存在,因此它不会添加到您的主题或插件中,因此请注意这一点,并添加唯一的$handle名称

注意:-在$handle的名称之前添加唯一名称或添加您自己的前缀 $handle like custom_jquery这是我们的自定义jquery$handle名称


参考站点:-

尝试从添加操作“wp队列脚本”、“添加主题脚本”替换;添加动作“wp_head”,“添加主题脚本”;是否在开发人员控制台中检查脚本和样式是否正在加载?此外,在wp_enqueue_脚本中,版本参数必须是字符串,即“1.1”,而不仅仅是1。1@Ravi“库马尔,我试过了,但也不起作用。”肖耶布·谢赫:是的,我检查过了。并且它们没有被加载。您正在签入管理端或前端?将最后一个参数设置为null以删除1.1文件的缓存版本,并在每次新文件时运行。谢谢,我的问题是$handle。我改了,文件现在被添加了。欢迎你。如果您得到了最难的解决方案,请向上投票。dev_ramiz_1707:-