WordPress.org

Ready to get started?Download WordPress

Forums

Images and JS are broken links on inside pages? (7 posts)

  1. jolaedana
    Member
    Posted 7 years ago #

    Hello all.

    I'm very perplexed and annoyed at this point. I walked away for an hour yesterday- walked away from a perfectly working site, and came back to an odd bug.

    I'm writing my very first WordPress template for my personal portfolio site. I had this template working, and it's valid XHTML and CSS (aside from the occasional error in the typed posts, most of which I've cleared up).

    You can see it here:
    http://www.audreysargent.com/

    You can see, when loading that page, there is a javascript that rounds the corners of the large magenta div on the left. There are also three images on the right.

    If you navigate to any of the inside pages, such as:
    http://www.audreysargent.com/category/news/

    You will see that the javascript no longer works, and the images don't load- however the background images are loading just splendidly (explain that one to me and you get a cookie.)

    I have everything but the PHP content calls seperated out into the header and the footer, so they are all using the exact same header footer files (in other words, just the content loading should be varied).

    This problem extends to not just the Page template, but the Archive template, and the 404 template as well. Any page other than the index page, in other words.

    I tried adding an absolute link to the location of the scripts and images, but that didn't work out either.

    The ONLY change I can think of in the last 48 hours was not made to this site at all, but to the BBpress forum I installed in another directory and in the same database, yesterday afternoon.

    I'm at my wit's end- anyone willing to give things a look or throw out an idea?

    Thanks and cookies.

  2. moshu
    Member
    Posted 7 years ago #

    That's just simply wrong path in calling the JS.
    Where is it installed?

  3. jolaedana
    Member
    Posted 7 years ago #

    Thanks for the quick response. I have it in the same folder as the rest of the template- what should the link be? What should image paths be? They're in the "images" directory in my theme folder as well.

    Also curious for future reference why it would have started off working and then stopped.

  4. quincewyss
    Member
    Posted 7 years ago #

    I have hard coded js files into WP if your giing to call the js file assrc="blah.js" then the js file need to go on the root level of your WP-site. or you can call it like src="wp-content/themes/name of the theme folder you have the js file in/your js file.js"

    Hope that helps

  5. jolaedana
    Member
    Posted 7 years ago #

    Ah ha.

    I keep forgetting that with these PHP sites paths go from the root directory, not necessarily the directory the file's in. Yay being completely new to things.

    I've moved the JS to the root directory of the installation, so now just calling it as "src="filename.js"" format should work.

    However, it still isn't working on the inside pages.

    Also, the images still aren't working either- and just for kicks, I added them to the main directory images folder as well, and they don't work from there either.

    Still puzzled.

  6. moshu
    Member
    Posted 7 years ago #

    1. not src="yourscript"
    but
    scr="/yourscript" - Big difference!

    2. In WP the best method is, if installed in the theme folder:

    <src="<?php bloginfo('stylesheet_directory');>/myscript.js"

  7. jolaedana
    Member
    Posted 7 years ago #

    Thanks Moshu.

    That second tip helped the images show up on all the page templates- I sort of dove into this and missed that, though it makes total sense.

    At first, this didn't work either:

    <script type="text/javascript" src="<?php bloginfo('stylesheet_directory'); ?>/rounded_corners_lite.inc.js"></script>

    Then I thought to check the permissions on the JS- the server default had set it too low for the browser to run it, so I set them to 755 and it works beautifully.

    Thank you for helping me out, it makes me feel INCREDIBLY silly when it's stuff like this- but then, with coding, I find it almost always is....

Topic Closed

This topic has been closed to new replies.

About this Topic