Tell me more ×
WordPress Answers is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have tried to use wp_enqueue, and I can't figure out how to implement it. I have resorted to just using bloginfo to link to my JS file. It works fine on my remote server, but as soon as I upload to my host the resource is not found. Not sure why this would be happening.

<script src="<?php bloginfo("template_url"); ?>/js/test.js">

this is the output the browser sees

<script src="http://fiftyfity.com/wp-content/themes/fiftyfityNew/js/test.js">
share|improve this question
What is the actual generated HTML (what the browser sees), not what your server template language sees? – jfriend00 Feb 21 '12 at 2:47
@jfriend00 I added the output the browser sees. – Anders Kitson Feb 21 '12 at 3:43
Is there a matching </script> tag? Other than that, the only other issue is whether something is seriously wrong in the HTML before this script tag or if the path to test.js is wrong. – jfriend00 Feb 21 '12 at 4:12
I took of the password protection so you can take a look fiftyfity.com/place-an-order the path should be correct, what else could it be. – Anders Kitson Feb 21 '12 at 4:34
Did you also upload the javascript files you're referencing to the host? From what you have described it sounds like you've uploaded the file where you make the script call, but not the Javascript files, hence why they can't be found. – Mark Duncan Feb 21 '12 at 13:30

closed as too localized by toscho Oct 16 '12 at 23:25

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, see the FAQ.

2 Answers

On your hosted server check the source code when the page loads to see what the path is that the bloginfo() is generating. When you installed locally maybe the path was different? Another option is to simply use the full url in the src tag rather than using php to generate the path.

share|improve this answer
the bloginfo() outputs fiftyfity.com/wp-content/themes/fiftyfityNew However even if I put in the full url in the src the resource is not found – Anders Kitson Feb 21 '12 at 3:37
When I go to that URL it's asking me for a password, is that meant to be there? Maybe that's why it's not rendering? – Anagio Feb 21 '12 at 3:46
yeah that's meant to be there. its just a plugin, it wasn't working before I added that plugin. – Anders Kitson Feb 21 '12 at 4:02
If you use Chrome, in the developer tool on the Network tab load your site and see what the server response is when that file loads. I get shown the password form, but the js file is 404ed – Anagio Feb 21 '12 at 4:06
Also on your home page the button-grad.png is 404ing and an ajax loader image. The problem is the path name to these in the CSS file is fiftyfity.com/wp-content/plugins/password-protect-wordpress and it should end in -wordpress-blog – Anagio Feb 21 '12 at 4:14
show 4 more comments

You are missing a </script> tag after this:

<script src="http://fiftyfity.com/wp-content/themes/fiftyfityNew/js/test.js">

should be this:

<script src="http://fiftyfity.com/wp-content/themes/fiftyfityNew/js/test.js"></script>

These resources in your page are not being found at the locations specified:

http://fiftyfity.com/wp-content/themes/fiftyfityNew/jQuery-ui-1/js/jquery-ui-1.8.17.custom.min.js
http://fiftyfity.com/wp-content/themes/fiftyfityNew/jQuery-ui-1/js/jquery-1.7.1.min.js
http://fiftyfity.com/wp-content/themes/fiftyfityNew/jQuery-ui-1/css/pepper-grinder/jquery-ui-1.8.17.custom.css
http://fiftyfity.com/wp-content/themes/fiftyfityNew/js/test.js

This is easy to see in the debug console in the Chrome debugger.

share|improve this answer
I added that, and it's still not working. – Anders Kitson Feb 21 '12 at 4:59
There are four resources specified in your page that are not being found where you're trying to load them from. I added those to my answer. – jfriend00 Feb 21 '12 at 5:11

Not the answer you're looking for? Browse other questions tagged or ask your own question.