#2356 closed enhancement (fixed)
bbp_has_search_results -> abord query if empty search terms = problems ?
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | 2.5 | Priority: | normal |
Severity: | normal | Version: | 2.3.2 |
Component: | Component - Search | Keywords: | needs-patch |
Cc: |
Description
Hi, in the function bbp_has_search_results(), there is this line :
// Don't bother if we don't have search terms if ( empty( $r['s'] ) ) return false;
This is, I think, a mistake :
I made a plugin that modify the bbPress query to fetch geolocated topics.
I would like results to be returned even if there is no search terms; if the user is "geo-searching" posts : it would then retrieve the last posts matching.
Maybe this line of code could be written in a different way !
eg.
// Don't bother if we don't have search terms if ( empty( $r['s'] ) ) && (apply_filters('bbp_abord_if_empty_search_terms',true,$r)==true) return false;
Not very clean, but that's the idea...
Change History (5)
#2
@
12 years ago
- Keywords needs-patch added
- Milestone changed from Awaiting Review to 2.5
Similar enough to #2355 where I think breaking apart bbp_parse_query() will address this.
Note: this is not exclusive to search, and happens when querying any other forum data.
Moving to 2.5.
#3
@
11 years ago
- Owner set to johnjamesjacoby
- Resolution set to fixed
- Status changed from new to closed
In 5162:
#4
@
10 years ago
Yeah, this is better;
But still, I have to run twice the query (if no search terms) :
- run the regular query (gets empty results)
-filter bbp_has_search_results
- run another query
This is heavy.
I still think my solution could help :
$has_search_terms = ( !empty( $r['s'] ) ); $do_search_query = apply_filters('bbp_do_search_query',$has_search_terms,$r); if ( $do_search_query ) ) { $bbp->search_query = new WP_Query( $r ); }
Meanwhile, I did this :