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(){
if(!is_admin()){
wp_deregister_script('jquery');
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');
wp_enqueue_script('jquery');
wp_enqueue_script('quicksand');
wp_enqueue_script('prettyPhoto');
wp_enqueue_script('easing');
wp_enqueue_script('custom');
}
}
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?