Support » Themes and Templates » Page ignoring template, need help…

  • Resolved Spencer Hill



    So I’m working on this site 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!

Viewing 4 replies - 1 through 4 (of 4 total)
  • archive.php is a reserved file name. Perhaps you are getting a conflict?

    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. and are examples.

    Any other thoughts?

    Thank you!

    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)…

    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.

    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?


Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Page ignoring template, need help…’ is closed to new replies.