I am trying to add jquery to my wordpress theme. I have used this code
function theme_name_scripts() {
wp_enqueue_script( 'jquery',true);
}
add_action( 'wp_enqueue_scripts', 'theme_name_scripts' );
But it is showing at head section . Not in footer section. What is the reason?
Try replacing:
With this
All that is saying is load the the JS file called jQuery that can be found in the ‘js’ folder of your theme folder.
Although I would always load in Google’s CDN version as recommended here:
EDIT
Alternatively, you could try putting a number at the end of the function line…like this:
EDIT
Maybe try this approach: How can I include Jquery in my WordPress footer?
Because it’s already registered for
header
, by default,WordPress
does it.You may use (an easy workaround)
You can’t omit optional parameters like you did in here
wp_enqueue_script( 'jquery',true);
and following won’t workAlso remember that, this (
$in_footer
, to put the script in footer) requires the theme to have the wp_footer() template tag in the appropriate place. Read this article.Also, you may use
Also, check this generator, it gave me following code generated by options I’ve chosen
You can generate your own code using this tool very easily.