I am trying to place my_javascript_file in the footer. According to the documentation $in_footer is the fifth value and it is a boolean so I have it set to true. Currently it doesn't show up anywhere, as far as I can tell from inspecting the code.

Got it to work, it was hidden in a div I forgot to close (oops)

UPDATE added fourth parameter as empty string ' '


function load_scripts() {
   wp_enqueue_script('my_javascript_file', get_template_directory_uri() . '/javascripts/app.js', array('jquery'),' ',true);

add_action('init', 'load_scripts');
/*add_action('wp_footer', 'load_scripts');/*DELETED THIS PART

FOOTER.PHP added wp_footer

    <!-- Main Row Ends -->
<?php wp_footer(); ?> /*added*/

  • No need to enqueue jQuery, you're supplying it as a dependency already, it will be included. Doesn't make sense to add load_scripts on wp_footer action, it comes too late, when all scripts have been enqueued already.
    – soulseekah
    Mar 11, 2012 at 19:46
  • You theme does not call wp_footer(), does it? The $in_footer parameter documentation goes on to state that ""This requires the theme to have the wp_footer() hook in the appropriate place.""
    – soulseekah
    Mar 11, 2012 at 19:47
  • @Soulseekah when you say supplying it as a dependancy already are you referring to the array(jquery) my theme does call wp_footer. I have added the footer.php file above now. Mar 11, 2012 at 19:52
  • You are not calling wp_footer, right now you're adding a non-existing function to the wp_footer action. Replace that line with wp_footer() and that's it. wp_enqueue_script('jquery'); is not required, you are already including jquery as a dependency (array('jquery')), cleaner code.
    – soulseekah
    Mar 11, 2012 at 19:57
  • @Soulseekah I added wp_footer to my footer.php file, but it still isn't working do I need the add_action in my functions.php file, I have tried with and without and it doesn't work still. Mar 11, 2012 at 20:01

1 Answer 1


You have true set in the 4th parameter (version), not the 5th.

    'my_javascript_file',                                 //slug
    get_template_directory_uri() . '/javascripts/app.js', //path
    array('jquery'),                                      //dependencies
    false,                                                //version
    true                                                  //footer

Also, as someone else mentioned, drop jquery enqueue, you've got it as a dependency, you don't need to enqueue it as well.

One last thing, your function name has a good chance of breaking your site somewhere down the line. load_scripts has a pretty large chance of conflicting with something from the core or from the theme/plugin.

  • Ok I have dropped the query. Ill change the function name, thanks for the suggestion. But this still doesn't work. I copied and pasted your script even. I copied old code so my version did have the parameter as the 5th. Also do I need the add action for wp_footer Mar 11, 2012 at 20:14
  • Shouldn't make a difference where it's enqueued. Does it enqueue properly if you set $in_footer to true.
    – mor7ifer
    Mar 11, 2012 at 20:17
  • Also //version is a string so should I not be placing empty quotes '' instead of false Mar 11, 2012 at 20:18
  • I thought that $in_footer is set to true already. Mar 11, 2012 at 20:20
  • My bad, I meant set $in_footer to false. $version's default value is false, it sets the version to the current version of wordpress. If you want no version, pass in NULL. Have you read the codex page about this function?
    – mor7ifer
    Mar 11, 2012 at 20:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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