I am using wordpress and I have some custom js in an external file in the root of my child theme. I want the reference to this js file written to the very end of the html document just before the closing body tag. I first tried hardcode the reference into footer.php. I verified that the reference to the external js file was correct in the html source but the javascript did nothing, and also did not throw any errors in firebug. The external file contained only:
jQuery(document).ready(function(){
alert('hello')
});
So after googling this problem for a while I found that I will need to use
wp_register_script
and
wp_enqueue_script
I found documentation here and here but I am not very familiar with php...
Currently, I have added:
add_action('wp_enqueue_scripts', 'load_javascript_files');
function load_javascript_files() {
wp_register_script('scripts', get_template_directory_uri() . 'wp-content/themes/maya_child/scripts.js', array('jquery'), true );
wp_enqueue_script('scripts');
}
to my child theme's functions.php file. The result is that the reference to my custom scripts file does not print out in the source at all
Am I maybe missing a step, or have I screwed up the php? Do I need to add something to header.php? or footer.php?