Support » Themes and Templates » Search results not using archive.php

  • Resolved kccricket


    I’m creating a personal theme based on the code and markup (but not the CSS) from the WordPress default theme. According to Template Hierarchy in the Codex, archive.php will be used if search.php doesn’t exist. Based on this information, I deleted search.php since default’s archive.php has an ‘if’ statement for search results.

    Unfortunately, it doesn’t seem to work that way. If I perform a search in the blog, it is definitely using index.php instead of archive.php. Feel free to try it yourself. Search for “lorem”, and it brings you to a page with “Announcements” as the second header. archive.php does not contain a h2 that just says “Announcements.” It should read “Search Results.”

    Is the Codex wrong or is there likely something wrong with my setup?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Codex is wrong. Search view will try to load search.php and then index.php.

    I just updated the codex, by the way.

    Edit: missed it, you win.

    Roger that. Is it planned to work the “wrong” way eventually, or was the misprint just a misprint?

    It will work as how it is right now, unless you complain enough (read: submit a bug) that search view has to load archive.php before index.php

    It was just misdocumentation, by the way. I suppose, because we wrote the docs after the software built.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Search results not using archive.php’ is closed to new replies.