wp_enqueue_script not loading my custom js file
-
01-11-2019 - |
Frage
I am using the following code below in my functions.php, However app.js is not found when I inspect it in the resources tab.
It is looking for it in http://localhost:8888/goodMorningMoon/javascripts/app.js?ver=3.3.1
when it should be looking in http://localhost:8888/goodMorningMoon/wp-content/themes/Good-Morning-Moon/javascripts/app.js?ver=3.3.1
How do I modify this code so it looks in the correct directory, do I need to add get_template_directory_uri(); somewhere, I have tried but to no avail.
Thanks in Advance
p.s this is located in my functions.php file, since I read from here http://smashingshare.com/2010/09/22/how-to-properly-add-javascript-files-to-your-wordpress-site/ that that is the proper way to approach including js files.
<?php
function load_scripts() {
wp_enqueue_script('jquery');
wp_enqueue_script('my_javascript_file', '/javascripts/app.js', array('jquery'));
}
add_action('init', 'load_scripts');
?>
Keine korrekte Lösung