WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a wordpress custom theme set-up and what i want is to create separate category templates, now seeing the template hierarchy i created the category-{slug} file and now when i am linking my custom JavaScript files inside its header part the script inserted in header is -

<script type="text/javascript" src="../literature/js/head.min.js"></script>

And the scripts in the footer to be executed after my content loads are -

            { jquery : "js/jquery.min.js" },
            { mousewheel : "js/jquery.mousewheel.js" },
            { mwheelIntent : "js/mwheelIntent.js" },
            { jScrollPane : "js/jquery.jscrollpane.min.js" },
            { history : "js/jquery.history.js" },
            { stringLib : "js/core.string.js" },
            { easing : "js/jquery.easing.1.3.js" },
            { smartresize : "js/jquery.smartresize.js" },
            { page : "js/jquery.page.js" }

Now i am getting a 404 error for all these files not present there , here's the firebug result :-

"NetworkError: 404 Not Found - http://localhost/deadman/wordpress/category/literature/wp-content/themes/testing/js/literature/core.string.js"

Now the things which i already tried are

  • "<?php bloginfo('template_url');/js/literature?>"
  • "wp-content/themes/testing/js/literature"

Anyone got a possible solution for this, i think it is because of the javascript prototyping i am using in the footer part but still i ain't able to fix this.

share|improve this question

Relative URLs are best avoided in WP, so use absolute URLs instead. Also, you should load javascript files using the correct method, ie by using the wp_enqueue_script() function hooked to the wp_enqueue_scripts action hook. Doing both of these things will sort out your issue. Using wp_enqueue_script() will also allow you to define dependencies so, for example, you don't load jQuery twice (in the event the theme or another plugin is already loading it). The page I linked to shows an example of the code you need.

share|improve this answer
I think i tried both the relative and the absolute urls, but am not able to work it out, anyway let me try the wp_enqueue_script() method – deadman Sep 11 '13 at 12:59

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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