Support » Fixing WordPress » Having some trouble with template heirarchy.

  • Resolved RollandRock


    Hi Guys,
    I recently started working on my first wordpress theme. It’s for my friend’s website, it’s not completely done yet but I’m having some trouble with the template heirarchy.

    I set my homepage to a static page named home. The blog page is a secondary page. I made a custom blog.php theme page. I also made home.php for my front page.

    The problem I’m having is my blog page is loading home.php template and my home page is just loading the page.php template. I’m not quite sure what I’m doing wrong here, any insight would be really appreciated.

    The website is

Viewing 7 replies - 1 through 7 (of 7 total)
  • Actually, I just tried making a custom template for the contact page as well. It is also loading page.php for it’s template. I do not know what I’m doing wrong here.

    are you assigning the templates?

    All pages get page.php unless you assign them from within the edit page view

    I actually got it work for my contact page (id 4) by making the page template page-4.php. This is not how I wanted to do it.

    When I go to edit page it says the only template I can assign is the archives.php file. Do I have to add something to the functions.php to allow it to notice these other templates?

    For my home I tried

    no…are you adding the appropriate header to the very top of each template?

    Template Name: Contacts

    Ahh, well that would be it. You’re the man Voodoo! Thanks

    glad we got it!

    Actually, according to WordPress’ own documentation, adding the custom template lines should not have been necessary for individual pages, as shown on this page.

    It actually seems to be broken.

    On one installation of WP ver. 2.8.4, I have working home.php, as well as several other individual template pages like sitemap.php, contact.php, about.php, etc. They work perfectly because they match the page name, so they are used instead of page.php, without any additional statement at the top identifying them as custom template files, and no editing is needed in the Page either – so I just leave it as default template and WP knows which template file to use based on the page name.

    You only need to create a custom template, and use the lines supplied by RVoodoo at the top, if it’s a template file you want to use across multiple pages which would not match either name, slug, or ID, to the template file. An example would be a set of pages where you want to call a different header, sidebar, or footer file.

    So RollandRocks attempts –

    For my home I tried

    – should have worked perfectly too, in keeping with the normal template heirarchy spelled out in the Codex. The fact that it didn’t indicates a broken installation.

    On another WP installation I have, of the very same version (2.8.4) the normal template heirarchy does not work.

    So the question remains, why not?

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Having some trouble with template heirarchy.’ is closed to new replies.