The Support Forums will be in read-only mode for a scheduled maintenance window on 01 September 2016 14:00 UTC - 20:00 UTC. More information.

How to get the template path within JavasScript? (1 post)

  1. Michelle Langston
    Theme Wrangler at Automattic
    Posted 6 years ago #

    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 http://www.mysite.com/library/js/carousel._prev.gif

    I want the path to be http://www.mysite.com/wp-content/themes/mytheme/library/js/carousel_prev.gif

    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.

Topic Closed

This topic has been closed to new replies.

About this Topic


No tags yet.