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>
You have
true
set in the 4th parameter (version), not the 5th.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.