[英]Find the double jquery.js include and remove it
我想在我的 WordPress 网站页脚中添加 j Query 文件,我已经做到了。 但问题是每当我在我的 WordPress 网站页脚中添加 j Query 文件时,滑块革命就会向我显示这样的错误。
革命滑块错误:您有一些 jquery.js 库包含在革命文件 js 包含之后。 这包括 make 消除了旋转滑块库,并使其不起作用。
找到双 jquery.js 包含并删除它。
当我删除 j Query 时,滑块革命工作良好。 但我想为我的工作添加 j Query 2.2.1,但我不能。 我如何解决它?
如果您正在使用任何缓存插件,如 wp 最快缓存、自动优化等,那么请删除它并检查它是否正常工作,因为由于某些 jquery 冲突而引发此错误。 如果它在禁用插件后工作,则意味着缓存插件存在问题。
解决方案可以在这里找到: https ://stackoverflow.com/a/23551006/3933603,来自@deweydb。
在主题文件夹的function.php
文件中添加这些行:
//remove the default jQuery script
add_filter( 'wp_default_scripts', 'change_default_jquery' );
function change_default_jquery( &$scripts){
if(!is_admin()){
$scripts->remove('jquery');
}
}
//inject a new one from a remote source
add_action('wp_enqueue_scripts', 'ocean_theme_scripts');
function ocean_theme_scripts() {
if(!is_admin()){
wp_register_script('jquery221', '//code.jquery.com/jquery-2.2.1.min.js', null, null, true);
wp_enqueue_script('jquery221');
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.