WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Hi I have just learned how to add jQuery to wordpress themes and it works but an error keeps appearing in the wordpress development tool.Here is the code that I posted:

    function register_js(){
        wp_register_script('jquery' , 'http://ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js');
        wp_register_script('quicksand', get_template_directory_uri() . '/js/quicksand.js', 'jquery');
        wp_register_script('easing', get_template_directory_uri() . '/js/easing.js', 'jquery');
        wp_register_script('custom', get_template_directory_uri() . '/js/main.js', 'jquery', '1.0', TRUE);
        wp_register_script('prettyPhoto', get_template_directory_uri() . '/js/jquery.prettyPhoto.js', 'jquery');


add_action('wp_enqueue_scripts', 'register_js');

Not the this is that I used to get the error $ and jQuery is not defined.To solve the $ problem in my main js file I used this:

jQuery(document).ready(function($) {})

Now I am only getting this errors:

Error: ReferenceError: jQuery is not defined
Source File: http://localhost/wordpress/wp-content/themes/01MyWork/js/quicksand.js
Line: 307

Error: ReferenceError: jQuery is not defined
Source File: http://localhost/wordpress/wp-content/themes/01MyWork/js/easing.js
Line: 39

Error: ReferenceError: jQuery is not defined
Source File: http://localhost/wordpress/wp-content/themes/01MyWork/js/main.js
Line: 2

The scripts seem to work the only problem is that this error is being thrown for every script that I load.How can I solve this?

share|improve this question
have you looked if all your js are included correctly in your page, they appear in the page? this type of error generaly is when some script you are calling are missing. maybe jquery-ui is missing, easing.js need jquery-ui if my memory is good try add a wp_enqueue_script('jquery-ui'); after enqueue jquery – Tribalpixel Aug 20 '12 at 13:28
up vote 3 down vote accepted

Your primary problem is that you are de-registering core jQuery. Don't do that. Ever. Period. If you get rid of that, your other scripts will work properly. Just do this:

function wpse62373_register_js() {
    if ( ! is_admin() ) {
        wp_enqueue_script('quicksand', get_template_directory_uri() . '/js/quicksand.js', array( 'jquery' ) );
        wp_enqueue_script('easing', get_template_directory_uri() . '/js/easing.js', array( 'jquery' ) );
        wp_enqueue_script('custom', get_template_directory_uri() . '/js/main.js', array( 'jquery' ), '1.0', TRUE);
        wp_enqueue_script('prettyPhoto', get_template_directory_uri() . '/js/jquery.prettyPhoto.js', array( 'jquery' ) );    

add_action( 'wp_enqueue_scripts', 'wpse62373_register_js' );

There are ways to replace core WordPress scripts properly, but I won't facilitate a bad practice such as replacing a core WordPress script by providing the answer.

share|improve this answer

I think your $deps need to be an array.


wp_enqueue_script('jquerylib', 'http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js');  
wp_enqueue_script('myscript', bloginfo('template_url').'/js/myScript.js'__FILE__), array('jquerylib'));  


wp_enqueue_script('jquerylib', 'http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js');  
wp_enqueue_script('myscript', bloginfo('template_url').'/js/myScript.js'__FILE__), 'jquerylib');  

like you did.

ref: http://codex.wordpress.org/Function_Reference/wp_register_script -> $deps

share|improve this answer
The problem still persists – Nistor Alexandru Aug 20 '12 at 8:35

Your Answer


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.