WordPress.org

Make WordPress Core

#22847 closed enhancement (wontfix)

Include search.php to archives template hierarchy

Reported by: alexvorn2 Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.4.2
Component: Template Keywords:
Focuses: 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 SergeyBiryukov17 months ago

  • Version changed from trunk to 3.4.2

comment:3 miqrogroove17 months ago

Use if ( is_search() ) or use if ( is_archive() or is_search () ) as appropriate for your output. These conditional functions are not tied to the template hierarchy, but to the query object in use.

I believe the request to modify the logic of is_archive() to be invalid.

Last edited 17 months ago by miqrogroove (previous) (diff)

comment:4 follow-up: SergeyBiryukov17 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.

comment:5 in reply to: ↑ 4 alexvorn217 months ago

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? :)

Last edited 17 months ago by alexvorn2 (previous) (diff)

comment:6 ocean9017 months ago

  • 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.

Note: See TracTickets for help on using tickets.