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 ' '
FUNCTIONS.PHP FILE
<?php
function load_scripts() {
wp_enqueue_script('jquery');
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
</div>
<!-- Main Row Ends -->
<?php wp_footer(); ?> /*added*/
</body>
</html>
load_scripts
onwp_footer
action, it comes too late, when all scripts have been enqueued already.wp_footer()
, does it? The$in_footer
parameter documentation goes on to state that ""This requires the theme to have thewp_footer()
hook in the appropriate place.""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.