WordPress.org

Forums

[resolved] Page ignoring template, need help... (5 posts)

  1. Spencer Hill
    Member
    Posted 4 years ago #

    Heya,

    So I'm working on this site http://alpine-property-management.theportlandco.com/blog/ and that particular page should be using the archive.php template (which I've specified in the "Template" drop down in the administration area already, but it seems to be ignoring this command and using index.php

    I haven't worked on this site in weeks so I have no idea why this issue started occurring (because previously it worked fine!

    Can anyone help? Thank you!

  2. s_ha_dum
    Member
    Posted 4 years ago #

    archive.php is a reserved file name. Perhaps you are getting a conflict?

  3. Spencer Hill
    Member
    Posted 4 years ago #

    I may be a little confused about archive/archives.php but I think I've got that sorted out as I'm running it exactly like this on other websites. http://www.woodburncompanystores.com/outlet-gals and http://www.vistacp.com/the-simple-truth are examples.

    Any other thoughts?

    Thank you!

  4. s_ha_dum
    Member
    Posted 3 years ago #

    The entire site is blank/white right now. I will return to my original point, though.

    WordPress has a number of template file names that it looks for to display particular pages. These are the reserved file names I mentioned. archive.php is one of them.

    When constructing a theme you can add your own templates by creating a file and adding something like (fron the Codex)...

    <?php
    /*
    Template Name: Snarfer
    */
    ?>

    ... to the top of the file.

    Reserved file name files do not show up in the choose a template box on the page edit screen. 'Template Name' files do show up there.

    You should either name a file archive.php, leave out the 'Template Name:' part, and let WordPress use it as that file is intended, or name it something else-- kinda-archive.php--, add the 'Template Name:' part, and select the template when you add a page. You should not do both. Doing both can cause some maddeningly frustrating weirdness. I've done it. I couldn't figure out why it sometimes worked and sometimes didn't until I realized that I'd used a reserved file name for my custom template.

    I don't know if that is your problem but is is something to consider well. The fact that it works sometimes isn't really proof that this isn't the problem. I experienced the same thing.

  5. Spencer Hill
    Member
    Posted 3 years ago #

    Thanks for your reply apljdi, I actually stumbled across the solution prior to your post, but it's basically the same thing you're saying here.

    Now, like you it sounds like, I had a firm understand of the Template Hierarchy but what I didn't fully understand (unknowingly) was that whatever page I define in the Settings -> Reading -> Posts page acts as the "blog"/"archive" section of the website, automatically using index.php regardless of whether or not I had defined a template for that page already.

    One thing that still doesn't make sense to me is why it uses index.php as the template instead of archive.php. According to the Template Hierarchy it should look for archive.php first. Can you explain this?

    Thanks!

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.