Support » Fixing WordPress » How to get the template path within JavasScript?

  • On my theme I have one of those horizontal sliding carousels that displays photos. It uses 2 arrow images to slide forward and backward. I want those arrows stored in my theme folder. How would I set the paths of those images within my javascript code to match my theme folder without hard-coding it? Here’s the javascript code (abbreviated just to show the problem spot):

    leftnav: ['library/js/carousel_prev.gif', 895, -26],
    rightnav: ['library/js/carousel_next.gif', -24, -26],

    As it stands, the path /library/js/carousel_prev.gif is treated as

    I want the path to be

    If I insert PHP in there, it just converts it to a string.

    Help! Thanks.

    Oh and if it’s relevant, this is a jQuery script, loaded on DOM ready.

  • The topic ‘How to get the template path within JavasScript?’ is closed to new replies.