I tried all the solutions I found on the internet, including the ones I found here, but nothing works on my theme - jQuery always load in header. I try to use the one from Google, but I would be happy to use the local one too, only in footer. This is what I have now:

   function my_init() {
    if (!is_admin()) {
        wp_register_script('jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js?ver=1.10.2', false, '1.10.2', true);

        // load a JS file from my theme: js/theme.js
        //wp_enqueue_script('my_script', get_bloginfo('template_url') . '/js/theme.js', array('jquery'), '1.0', true);
add_action('init', 'my_init');

Any ideas why no solution works for me?

  • 1
    So you have a wp_footer() defined in the footer, right? – Mayeenul Islam Feb 25 '14 at 1:12
  • yes, I do have. – whitelord Feb 25 '14 at 1:39
  • Maybe you have another script loading it via a plugin, or maybe it's hard-coded in the theme. – Wyck Feb 25 '14 at 1:59

You need to load your scripts in the footer so you'll need to add them to the functions.

This method works for parent themes dependent on jQuery.

For child themes





Example code for parent themes:

function wpsites_load_scripts() {

wp_enqueue_script( 'script-name', get_template_directory_uri() . '/js/example.js', array(), '1.0.0', true );

add_action( 'wp_enqueue_scripts', 'wpsites_load_scripts' );

The 5th parameter determines where the script is loaded:


Normally, scripts are placed in of the HTML document. If this parameter is true, the script is placed before the end tag. This requires the theme to have the wp_footer() template tag in the appropriate place.

Default: false

Source http://codex.wordpress.org/Function_Reference/wp_enqueue_script

  • sorry, I do not understand how that is related to loading jQuery in the footer. I'm only interested in jQuery. – whitelord Feb 25 '14 at 1:55
  • 2
    The relation is that jQuery cannot load in the footer unless every other script that relies on it also loads in the footer. – Otto Feb 25 '14 at 1:58
  • You need to tell WordPress where to load each script using the 5th parameter. The default for $in_footer is false so you need to change that to true for each script in using the wp_enqueue_scripts function so it hooks into wp_footer(). – Brad Dalton Feb 25 '14 at 2:01
  • I use minify, with WTC, and I'm loading all the javascrip in footer. The only script that is loading in header is css. is css required to load in the footer too? – whitelord Feb 25 '14 at 2:02
  • I would check that all scripts using jQuery are loaded in the footer and then flush all caching. CSS doesn't use jQuery. – Brad Dalton Feb 25 '14 at 2:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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