Support » Fixing WordPress » Understanding 1.5 file hierarchy

  • I need a little clarification to understand the way the file hierarchy works in 1.5. I understand that much of it can be cleaned up by posting <base href="" /> in the header, but I want to really understand the new hierarchy. I’ll use images as an example.

    Since index.php in the root directory calls the index.php from the theme directory (and all the includes), links to images in a post using a theme are from the root directory or the theme directory?

    So a link to a graphic in would be listed as images/cars/car1.jpg and work just fine or would it be relative from the theme directory as ../../../images/cars/car1.jpg.

    Can you see some of my confusion. The base reference would be easier, but I just want to understand the actual physical hierarchy.


Viewing 7 replies - 1 through 7 (of 7 total)
  • Because of the way it works, everything will be “relative” to the index.php file that is at the root of the install. This is because everything is included from there.

    This is applicable for any HTML element. Including files via PHP is a different beast, but for HTML things, you can assume that it’s realtive to the teeny index.php file in the root.

    However, in the exames you gave, it’s likey to work anyway.

    If you have installed at the root ( ie ) then the path “../../../../../../../../../../images/hi.jpg” will work just as well as “images/hi.jpg”.

    My preference is to just do “/images/hi.jpg” since I don’t worry about it one way or the other then. 😀

    This is a problem that crops up with custom permalink generation of virtual directories, and is more a web issue than a WP one, as all paths are relative to the location of a page as it appears within your url. If one were to actually point to

    your up-path notation would work. But with

    it tries to find ‘images’ in a directory three up from the root (which obviously fails). With this in mind, a link to

    is best referenced as


    The initial slash specifies the path begins at the root of the site.

    Now, when it comes to requiring a path within theme templates specifically for things like an image directory for that theme, the tag bloginfo() provides new 1.5-specific parameter options for that:


    Herein lies the problem that first started this for me. For me, without the base reference, “/images/” goes past “public-html” where all my public html (and php) files are listed (which technically makes it: “”) and it can’t find the images directory because it isn’t in the real “root” (“”) but in the “public-html/images/”…oh, I’m confusing myself.

    This was so much easier when my old server just had everything dumped in the root without having the public files in a public file directory. Ah, for the simplier life. 😉

    .htaccess redirect helps a lot, but I want to keep it clean and not have a WHOLE bunch of redirects when I don’t have to. The upkeep of all of these can be tiresome when things change.

    I think your explanations help me understand this a lot better. Thanks!

    “Herein lies the problem that first started this for me. “

    You just need to make everything difficult, don’t you? ;)

    My life story.

    I made a custom php function that pulled the info out from the http headers of the directory structure the page thought it was in – parsed that, and then used it to make sure I was working from the base directory.

    so in the php it just looked like:

    href=”<?php linkbase() ?>/myfolder/myfile.jpg”

    ah, excellent. So this is a plugin or a custom function you edited into…the index.php page?

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Understanding 1.5 file hierarchy’ is closed to new replies.