Javascript not kicking in

Hello all.
I tried putting this bit in the header & footer.

<script src="<?php echo get_template_directory_uri(); ?>/myJs.js"></script>

just to start testing out and practicing javascript
but i get this error message in the console (using chrome)

http://localhost/site_a/wp-content/themes/twentyfourteen/myJs.js 404 (Not Found)

Am using a child theme of 2014.I don’t want to enque the script yet.
and this should work. What am i doing wrong please? it should just give console info btw

Thank you

So your js file must be in a different location to where that path is looking for it.

Simply move the js to the right folder.


The get_template_directory_uri() function will always return the directory of the template, which, in a Child Theme, per the “Template:” header tag in style.css, is the Parent Theme.

If you need to reference the Child Theme directory URI, you should instead use the get_stylesheet_directory_uri() function.



Thank you Pullo!
Dead on!

odd as i am pretty sure i used the previous get template uri to place images. will have to test w/the new get.