Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/79.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
将引导模板转换为Wordpress时未加载jQuery_Jquery_Wordpress_Twitter Bootstrap - Fatal编程技术网

将引导模板转换为Wordpress时未加载jQuery

将引导模板转换为Wordpress时未加载jQuery,jquery,wordpress,twitter-bootstrap,Jquery,Wordpress,Twitter Bootstrap,jQuery文件不会从引导模板加载。我正在将其转换为Wordpress主题。我在functions.php文件中尝试了许多不同的脚本排队方式。我尝试过注销jQuery,但没有成功 Chrome dev tools给出了一个404错误,并将其归档以加载js文件 <?php function willow_rivers_files() { wp_enqueue_style('font-awesome', get_theme_file_uri('vendor/fontawesome

jQuery文件不会从引导模板加载。我正在将其转换为Wordpress主题。我在functions.php文件中尝试了许多不同的脚本排队方式。我尝试过注销jQuery,但没有成功

Chrome dev tools给出了一个404错误,并将其归档以加载js文件

<?php 
  function willow_rivers_files() {
    wp_enqueue_style('font-awesome', get_theme_file_uri('vendor/fontawesome-free/css/all.min.css'));
    wp_enqueue_style('bootstrap-files', get_theme_file_uri('vendor/bootstrap/css/bootstrap.min.css'));
    wp_enqueue_style('custom-style-from-template', get_theme_file_uri('css/grayscale.min.css'));
    wp_enqueue_style('custom-style', get_theme_file_uri('style.css'));
    wp_enqueue_style('google-font-round', '//fonts.googleapis.com/css?family=Varela+Round');
    wp_enqueue_style('google-fonts-nunito', '//fonts.googleapis.com/css?family=Nunito:200,200i,300,300i,400,400i,600,600i,700,700i,800,800i,900,900i');  

    wp_enqueue_script('jquery', get_template_directory_uri('vendor/jquery/jquery.min.js'), NULL, '1.0', true);
    wp_enqueue_script('jquery-easing', get_template_directory_uri('vendor/jquery-easing/jquery.easing.min.js'), NULL, '1.0', true);
    wp_enqueue_script('jquery-easing', get_template_directory_uri('js/grayscale.min.js'), NULL, '1.0', true);
  }

  add_action('wp_enqueue_scripts', 'willow_rivers_files');
?>

WordPress有自己的jquery库,您无需单独包含它

要从WP加载jquery,只需在JS队列的第三个参数中添加jquery库的依赖项

请尝试以下方法:

  • 删除:
  • wp_enqueue_脚本('jquery',get_template_directory_uri('vendor/jquery/jquery.min.js'),NULL,'1.0',true)

  • 对于以下两行,将其从
  • wp\u enqueue\u脚本('jquery-easing',get\u template\u directory\u uri('vendor/jquery easing/jquery.easing.min.js'),NULL,'1.0',true);
    wp_enqueue_script('jquery-easing',get_template_directory_uri('js/grayscale.min.js'),NULL,'1.0',true)

    wp\u enqueue\u脚本('jquery-easing',get\u template\u directory\u uri()。/vendor/jquery easing/jquery.easing.min.js',数组('jquery'),'1.0',true);
    wp_enqueue_script('jquery-easing',get_template_directory_uri()。/js/grayscale.min.js',array('jquery'),'1.0',true)

    请确保路径get_template directory_uri()将返回给您 您需要在“/”前面添加路径的其余部分


    希望这对你有帮助

    当我到达时,
    get\u template\u directory\u uri()
    不接受任何参数-因此应该像
    wp\u enqueue\u script('jquery',get\u template\u directory\u uri()。/vendor/jquery/jquery.min.js',NULL,'1.0',true)那样进行操作仍然没有乐趣,我正在本地MAMP服务器上工作,这有什么不同吗?没有。你能告诉我你现在犯了什么错误吗?您还可以提供inspect或view source中enqueue JS URL的屏幕截图吗?加载资源失败:服务器在控制台中的响应状态为404(未找到)。虽然脚本在页脚中看起来很好。。恐怕我看不到如何添加屏幕快照安装lightshot获取屏幕快照并上传到lightshow云。它生成url。把它贴在这里。或者在这里截图并上传。()并将URL发送给我。404获取什么资源。我想您已经从footer和footer.php文件中删除了脚本标记,该文件是您调用get_footer()函数的主题。您添加的代码将通过get_footer()函数调用。我希望您通过查看页面的源代码仔细检查是否包含jquery.js,以及您在functions.php文件中排队的js文件是否显示。