Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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 -

<script>
        head.js(
            { 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" }
        );
</script>

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

1 Answer 1

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

 
discard

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.