Support » Themes and Templates » hierarchy help – totally confused


    Explains the hierarchy, and in my attempts to create a slightly complciated wordpress design from scratch, I’ve confused myself further.

    In this instance I have the following templates:


    I don’t have an index.php, and I wonder if that’s a bad thing? Ok let me explain I doubt I’ll see a reply, but here goes:

    home.php will be the front page
    category-x.php and header-x.php match up to load the next page

    What I then need is for the user to be able to click a link, and then it displays another template if y0u like which contains the full entry of the post.

    1) In this case I still want to use a customer header, so would this be a case of using the single-x.php? Or is categor-x.php a low-level tempalte where single.php is higher and therefore takes priority?

    2) can I get away with using the loop ONLY in single-x.php if the above case is true?

    I don’t know where, or how I could use index.php in this case. I’d welcome advice on whether this is the right approach as I’ve stalled working on my site.


Viewing 7 replies - 1 through 7 (of 7 total)
  • replace the home.php with index.php. It IS the same thing and you are just hurting yourself in the long run by changing it.

    Just keep in mind that index.php is the final fallback template for everything else. Even if you don’t think you need it, it doesn’t hurt to have one in there, and it’s likely something will pop up somewhere down the road where you’ll kick yourself for lacking it (though you can certainly have home.php and index.php together).

    Index php is not the same thing as home php. Obviously.

    Thanks for the info Kaf & Root.

    @kaf What should the index.php relate to? I think the difficulty in my understanding is what exactly do I make it look like? What is the likely thing it is meant to fall back on? That’s the bugger.

    The other thing is how to get the single.php for each cat to display a single item post.

    An example call in category.php is:

    <?php load_template( TEMPLATEPATH . '/header-2.php'); ?>

    It’s the same in the single.php in this case. However, what comes next and in what file? Does single.php contain:

    <?php load_template( TEMPLATEPATH . '/category-2.php'); ?>

    or does category 2 contain:

    <?php load_template( TEMPLATEPATH . '/single-2.php'); ?>

    I can’t get a single item to display

    Jinsan – the benefit and purpose of the template hierarchy is that we do not have to mess with headers, php conditionals or other hoodickies. If a standard index php file is saved as category php then every time a category is called that is the file it uses. So that is the file to edit for your cat related template. Once you have it running for categories then individual cats will be more intuitive to you. But you are on the wrong lines if you are messing with headers. Do one or the other.

    I hear what you’re saying root – the purpose in this case for a different header.php is one of cosmetics. Not understanding the php conditional statements I don’t know any other way to create a unique header for each category.

    Part of my problem is confusion mixing with ambition. In any case, the idea I’m trying to achieve is:

    home.php> click item in cat box > send user to cat page > user clicks item > forwarded to single template for cat.

    Reckon it’s too much to make the user click twice for the same item? I’m heading in that “don’t go there, and keep it bloody simple” train of thought. It would simplify the headache of trying to create essentially two templates for each category – a single template and a category template (though I have done this before, I just don’t rememeber how).

    The method would make things more organised and make it easier for the user to access adidtional content though

    Well your issue then isnt about headers. It is about loading different CSS for each template. You can do it a number of ways. You can hard code the extra CSS in each cat template. You can use one mighty if else conditional in the header php. Or you can import from within the template. Or you could use the body id and use one CSS sheet throughout. That should get you started. I need to keep my hand in. 🙂

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘hierarchy help – totally confused’ is closed to new replies.