Opened 14 years ago
Closed 14 years ago
#18485 closed defect (bug) (duplicate)
Search with blank criteria returns results in wrong template file.
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Milestone: | Priority: | normal | |
| Severity: | major | Version: | 3.2.1 |
| Component: | Template | Keywords: | |
| Focuses: | Cc: |
Description
If you use the search but leave the criteria field blank, the results are returned in the standard template instead of search.php
Attachments (1)
Change History (14)
#2
@
14 years ago
Yes, that's exactly what I mean. Rather inconvenient because it's probable that a user could click search with no criteria...
#4
@
14 years ago
- Resolution set to fixed
- Status changed from new to closed
Thank you for the quick response!
#5
@
14 years ago
- Resolution fixed deleted
- Status changed from closed to reopened
Tickets are closed when a commit is made to the WordPress trunk to fix the issue, not when a patch is posted
#6
@
14 years ago
Yeah, that fix didn't work anyway. I thought it did... but when I looked back at the root of the site, every page is showing up as search results template now.
#7
@
14 years ago
- Keywords has-patch removed
Yep, scratch that. I should have tested more thoroughly.
#8
@
14 years ago
Is there somewhere else in the code that the $qvs? variable is checked in regards to templates?
#10
@
14 years ago
WordPress prefills all query vars (including s) with empty values, so that's probably by design.
A workaround might look like this:
function load_search_template_for_blank_criteria() {
global $wp_query;
if ( isset( $_GET['s'] ) )
$wp_query->is_search = true;
}
add_action('template_redirect', 'load_search_template_for_blank_criteria');
#11
@
14 years ago
Ok - I un-commented 1387 and changed 1470 to
if (isset($_GET['s'])) {
This works too.
Just to confirm, You're refering to something such as:
http://example.com/?s=?WordPress treats empty query vars as if they don't exist, therefor, in that situation it'd most likely load the blog index.