• Hello,
    I’m new to wordpress so forgive me if my questions are naive. I am using a child theme based on twenty-twelve. The page in question is: http://www.bellasjardin.com/etsy-shop/
    I have added code to the page that calls a javascript to display a list of Etsy listings. It works fine and the script is found as: “http://www.bellasjardin.com/mycontent/etsyapi.js” as expected.

    However if I change my script directory structure to: /mycontent/etsyapi/etsyapi.js, I get 404 error. This is because rather than “http://www.bellasjardin.com/mycontent/etsyapi/etsyapi.js”, a legitimate path, it gets converted to: “http://www.bellasjardin.com/etsy-shop/mycontent/etsyapi.js” and the script does not exist there. Why is “etsy-shop” added to my script url? I noticed that everything works as expected prior to publishing my page. That is, while in draft mode and while previewing, it works as expected and my url paths are correct. The observed problem occurs only after it’s been published.

    Sample code that works, but fails if I change my url to “/mycontent/etsyapi/etsyapi.js”

    <script>// <![CDATA[
    $.getScript("/mycontent/etsyapi.js",function(){ getlistings("bellasjardin","title,price,url",100,"large"); });
    // ]]></script>

    Thanks so much!

The topic ‘javascript code in wordpress pages adds the page-id to the script url’ is closed to new replies.