Opened 5 months ago
Closed 5 months ago
#22847 closed enhancement (wontfix)
Include search.php to archives template hierarchy
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | Template | Version: | 3.4.2 |
| Severity: | normal | Keywords: | |
| Cc: |
Description
If we will use
if( is_archive()) {
echo 'test';
}
in the search.php file willget a false result from is_archive function... I think that search file is an archive too because it contains old posts...
Change History (6)
comment:2
SergeyBiryukov — 5 months ago
- Version changed from trunk to 3.4.2
comment:3
miqrogroove — 5 months ago
Use if ( is_search() ) or use if ( is_archive() or is_search () ) as appropriate for your output. These conditional functions are not connected to the template hierarchy in any way.
I believe the request to modify the logic of is_archive() to be invalid.
comment:4
follow-up:
↓ 5
SergeyBiryukov — 5 months ago
- Keywords close added
in the search.php file willget a false result from is_archive function...
Same as in index.php (which acts as a fallback if search.php is missing), so the template isn't actually relevant here. The search results page isn't considered an archive, and changing that may cause backwards compatibility issues.
search.php have a lot in common with archives template files: (tag.php, author.php, category.php, etc)
- old posts
- heading in all default themes
- excerpt text
it's just an idea that can make some things more easy to use.. if the search.php file will be missed, archives.php will be used before index.php...
and if function is_search will be available too for backwards compatibility.
I don't think that it's a big change for everyone.
btw, the '2nd-opinion' tag is for added opinion or for waiting for a second opinion? :)
- Keywords 2nd-opinion close removed
- Milestone Awaiting Review deleted
- Resolution set to wontfix
- Status changed from new to closed
This change could break many themes because it's not really expected, that is_archive returns true for a search. Also, a search can include new/current posts too.
I don't think that it's a big change for everyone.
It is.

http://codex.wordpress.org/images/1/18/Template_Hierarchy.png