Hi I am jsut recently learning to develop wordpress themes and at first I added the jquery script and other scripts like this:
<script src="<?php bloginfo('template_directory') ?>//ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js"></script>
But today while doing some tutorials I found that this is not the best way of doing things , so I started searching on the internet and I found how to do it:
function register_js(){
wp_deregister_script('jquery');
wp_register_script('jquery' , '//ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js');
}
add_action('init' , 'register_js');
But for some reasons all the scripts I have on my page say that jQuery is not defined or $ is not defined.What am I doing wrong?
You are missing the wp_enqueue_script function.
Detailed here: http://codex.wordpress.org/Function_Reference/wp_enqueue_scrip
WordPress Example: