Hey experts,
I’m converting an HTML template to a WordPress theme and have hit a snag. I set up the CSS and JS files to be enqueued at the top and bottom of the page respectively, but all the links at the bottom of the page (that is, the JS files) aren’t showing as complete URIs, just the relative path, which is incomplete, and the server returns a 404. The one script that loads in the header has the complete URI and loads fine.
Examples:
Script that loads in the header, and one that loads in the footer:
function add_script()
{
wp_register_script(‘j.mod’, get_template_directory_uri() . ‘/js/modernizr.js’, array (), 1.1, false);
wp_enqueue_script( ‘j.mod’);
wp_register_script(‘j.lsg’, get_template_directory_uri() . ‘/js/layerslider/js/greensock.js’, array ( ‘jquery’ ), 1.1, true);
wp_enqueue_script( ‘j.lsg’);
And here are the resulting script tags sent by WP to the browser, first in the header:
<script type=’text/javascript’ src=’http://localhost/mcc-wp/wp-content/themes/PressView/js/modernizr.js?ver=1.1′ id=’j.mod-js’></script>
And now in the footer:
<script src=”js/layerslider/js/greensock.js”></script>
I swear the only difference I can see is the true or false for loading in the footer.
Can anyone tell me what’s wrong here?
ETA: have confirmed that the jquery dependency and true/false don’t have any effect at all on the tag that’s rendering wrong. That is to say it looks like get\_template\_directory\_uri() is returning null after the first time I call it in the scripts section…
[ad_2]