Alex Rivera | Logout

wp_enqueue_script in the footer

Asked 2012-03-19T17:42:06.063
21

Having problems enqueuing a script in the footer.

wp_deregister_script('jquery');
wp_enqueue_script('jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js', array(), false, true);

Here's the wp_enqueue_script definition:

wp_enqueue_script( 
     $handle
    ,$src
    ,$deps
    ,$ver
    ,$in_footer 
);

As you can see I am setting $in_footer to true. This does not work for me. Without that argument it works fine and puts it in header.php. Why doesn't it work with $in_footer?

Edit
Report

1 Answer

11

Make sure you have the wp_footer() right before the </body> tag. See the $in_footer parameter for more info. You also need to call this before wp_head has run. Try also using this action.

add_action('wp_enqueue_scripts', 'add_scripts_to_pages');

Another thing to try is using NULL as 3rd and 4th parameters.

answered 2012-03-19T18:21:25.947

Your Answer