Wordpress Jquery 与插件的冲突 [英] Wordpress Jquery Confliction with Plugin
问题描述
我正在为客户建立一个 Wordpress 网站,并且它将有一个电子商店.我正在使用 wp-ecommerce.所有商店页面都加载了 javascript 错误:
I am building a Wordpress website for a client and it is going to have an e-store. I'm using wp-ecommerce. All of the store pages are loading with a javascript error:
http://www.thecollectiveclothingco.com/products-page/t-衬衫/
jQuery("form.product_form").livequery is not a function
[Break On This Error] jQuery("form.product_form").livequery(function(){
经过一些广泛的谷歌时代后,我相信我已将该问题诊断为脚本冲突.换句话说,WP 或插件本身正在提供 jquery,我还将它包含在网站上的其他一些内容中.当我删除我的 jquery 脚本调用时,问题就消失了,商店工作正常.但我需要那个 jquery...
After some extensive google-age, I believe I've diagnosed the issue as a script conflict. In other words, either WP or the plugin itself is serving up jquery, and I'm also including it for some other things on the site. When I delete my jquery script call, the issue goes away and the store works fine. But I need that jquery...
我已阅读有关使用 WP enqeue 解决问题的文章:
I've read about using WP enqeue to fix the issue:
function my_init_method() {
if (!is_admin()) {
wp_deregister_script( 'jquery' );
wp_register_script( 'jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js');
wp_enqueue_script( 'jquery' );
}
}
add_action('init', 'my_init_method');php wp_head();
我相信我做得对,但似乎没有解决任何问题.
I believe I've done this right, but does not seem to be fixing anything.
有什么想法吗?再次感谢.
Any ideas? Thanks again.
推荐答案
好吧,我想通了...它是解决问题的入队脚本.我 wp(头);必须在注销和入队部分之前出现.我一定是读错了文档.这是我添加到标题中的内容:
Alright, I figured it out... it was the enqueue script that fixed things. I wp(head); had to come before the deregister and enqueue part. I must have read the documentation wrong. Here's what I added to my header:
<?php
wp_head();
wp_deregister_script('jquery');
wp_enqueue_script('jquery', MYURL .'http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js', FALSE, '1.4.4');
?>
这篇关于Wordpress Jquery 与插件的冲突的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!