Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Hey guys, thanks in advance for your help. I've done my research and I'm a bit stumped with this...

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(){ 

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...

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.

EDIT:

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');
 ?>
share|improve this question
    
Queue-related stuff should be hooked to init as per your earlier snippet. Anyway you will get it with some practice, I recommend to carefully go over this post How to load JavaScript like a WordPress Master, it's very comprehensive and shows variations in approaches well. And btw you should put solution in answer as you started to (I see you had deleted it), not in question. –  Rarst Jan 30 '11 at 22:02
add comment

2 Answers

up vote 3 down vote accepted

There are currently two copies of jQuery loaded on site:

  1. In header there is jQuery bundled with WordPress, likely requested by some plugin.
  2. In footer there is jQuery from Google CDN, likely added by your code?

Obviously this is one too many. There are couple of ways to handle it:

  1. If you are fine with using bundled copy you need to register/enqueue your scripts and declare jquery in dependencies, see in Codex: wp_register_script(), $deps argument.
  2. You can re-register jQuery to Google CDN, still good idea to register your script with it as dependency.

Your code seems fine except this at end php wp_head();, php makes no sense, and wp_head() call should be in theme.

share|improve this answer
    
Rarst, thank you so much. That was just what I was looking for. –  Redlist Jan 30 '11 at 21:50
add comment

There's a nice solution to this at this dude's site: http://www.mogmachine.com/stop-wordpress-loading-jquery-in-wp_head/

Which is solved by putting the deregister jquery, call your own source, re-register jquery commands into your functions.php in your theme. You can avoid plugins and collisions by just calling your own instead of WP's.

Worked for me.

share|improve this answer
2  
Just make sure your alternative jQuery version matches the version WordPress uses exactly. Outdated versions will break sometimes (admin bar for example). –  toscho Mar 19 '12 at 8:51
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.