Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have looked but no where seems to cover how to place jQuery into the footer, at least not the way I have it in my theme, is there a way to place the following into the footer?

// Load jQuery
function my_register_jquery_function() {
    wp_deregister_script('jquery');
    wp_register_script('jquery', ("http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"), false, '1.7.1');
    wp_enqueue_script('jquery');

    wp_enqueue_script(
        'cookie'
        , get_stylesheet_directory_uri() . '/js/jquery.cookie.js'
        , array('jquery')
    );
    wp_enqueue_script(
        'easing'
        , get_stylesheet_directory_uri() . '/js/jquery.easing.1.3.js'
        , array('jquery')
    );
    wp_enqueue_script(
        'nivo'
        , get_stylesheet_directory_uri() . '/js/jquery.nivo.slider.js'
        , array('jquery')
    );
    wp_enqueue_script(
        'setup'
        , get_stylesheet_directory_uri() . '/js/setup.js'
        , array('jquery')
    );
}

add_action('wp_enqueue_scripts', 'my_register_jquery_function');
share|improve this question
add comment

1 Answer

Sure. Set the fifth parameter of wp_enqueue_script or wp_register_script as true, and that script will be placed in the footer.

For example, your line

wp_register_script('jquery', ("http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"), false, '1.7.1');

should be

wp_register_script('jquery', ("http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"), false, '1.7.1', true);

And if you ever don't need/want to specify a version number, just set the fourth parameter to false.

More info: http://codex.wordpress.org/Function_Reference/wp_register_script

By the way, to make sure you're avoiding any conflicts, I would recommend you prefix the names of all your custom scripts.

share|improve this answer
    
Thanks, but, strange that didn't do anything? –  a_knife_a_fork Aug 29 '12 at 13:01
1  
"Hmmm, strange that didn't do anything?" - What actual code did you use?. Note also: de-registering a core script and registering a custom version can and will have unintended consequences. –  Chip Bennett Aug 29 '12 at 13:04
    
I used wp_register_script('jquery', ("http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"), false, '1.7.1', true); –  a_knife_a_fork Aug 29 '12 at 13:08
    
"unintended consequences" that doesn't sound good is there a safe way of enqueuing the scripts? –  a_knife_a_fork Aug 29 '12 at 13:10
1  
"is there a safe way of enqueuing the scripts?" - Yes: don't de-register core scripts in order to enqueue custom versions. Just use the core-bundled, core-registered version. –  Chip Bennett Aug 29 '12 at 13:33
show 2 more comments

Your Answer

 
discard

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.