问题描述
大家好,谢谢您的帮助.我已经完成研究,对此感到有些困惑...
Hey guys, thanks in advance for your help. I've done my research and I'm a bit stumped with this...
我正在为客户建立一个Wordpress网站,并且它将拥有一个电子商店.我正在使用wp-ecommerce.所有商店页面都加载了javascript错误:
I'm 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-shirts /
jQuery("form.product_form").livequery is not a function
[Break On This Error] jQuery("form.product_form").livequery(function(){
经过一段广泛的Google时代,我相信我已将问题诊断为脚本冲突.换句话说,无论是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(head);必须在取消注册和入队之前进行.我一定看错了文档.这是我添加到标题中的内容:
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与插件冲突的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!