如何修复两个版本的jquery冲突
有一个jquery冲突,你能帮我解决吗?我想这里发生的是WordPress正在加载它自己版本的jquery,而你也在从主题手动加载一个 在函数文件中,包括以下脚本:如何修复两个版本的jquery冲突,jquery,wordpress,Jquery,Wordpress,有一个jquery冲突,你能帮我解决吗?我想这里发生的是WordPress正在加载它自己版本的jquery,而你也在从主题手动加载一个 在函数文件中,包括以下脚本: <script type='text/javascript' src='http://labellaintimates.com/wp-includes/js/jquery/jquery.js?ver=1.8.3'></script> <script type="text/javascript" src=
<script type='text/javascript' src='http://labellaintimates.com/wp-includes/js/jquery/jquery.js?ver=1.8.3'></script>
<script type="text/javascript" src="http://labellaintimates.com/wp-content/themes/labella/jquery.js"></script>
我怀疑你的主题(或插件)可能已经注册了你的本地jQuery文件,只是没有注销WordPress包含的一个,所以你应该仔细研究一下,确保你没有两次调用同一个文件
更新-您可以在这里找到更多细节:您只需要一个。它们都是相同的东西,但可能是不同的版本。如果您的一个脚本在删除一个脚本后损坏,那么您的脚本可能无法与该特定版本一起工作,但在大多数情况下应该可以正常工作。为什么不删除一个脚本呢。
function my_scripts_method() { // Creates the my_scripts_method function
wp_deregister_script('jquery'); // Deregisters the built-in version of jQuery
wp_register_script('jquery', 'http' . get_template_directory_uri() . '/YOUR-JS-PATH.js', false, null, true); // Registers your javascript file
wp_enqueue_script('jquery'); // Activates the jQuery script
}
add_action('wp_enqueue_scripts', 'my_scripts_method'); // Tells WordPress to run the my_scripts_method function