It might be the simplest question but I can't find why my JavaScript files and images are not recognized by WordPress. I put all my JS files and images in my theme's folder, so I created a folder "word" inside "theme", with all the content and then I added my files. But the website doesn't recognize the path to the JavaScript or the images. Could you please tell me what i'm doing wrong?

I used it like that in the header page :

<script src="jquery.js" type="text/javascript"></script>

You need to give the full path to your theme files. To get the URL of your theme, use the WordPress function bloginfo( 'template_directory' ); so at a minimum you would need:

<script src="<?php bloginfo( 'template_directory' ) ?>/jquery.js" type="text/javascript"></script>

However, scripts / styles should really be "enqueued" using wp_enqueue_script(); (see http://codex.wordpress.org/Function_Reference/wp_enqueue_script)

I would recommend taking a look at some other themes to see how they include thetheme files like this. Also the Codex page on Theme Development is a good place to start: http://codex.wordpress.org/Theme_Development


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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