I've had numerous clients request some functionality enhancement to the keyword searching functionality, mainly around the fact that every word is searched using a LIKE comparison operator so php developer would return any results for php AND any results for developer
When this is then checked for post meta, a LIKE is generated using %php developer% which is a bit inconsistent with how the s parameter works for searches. So the native s parameter in WP_Query does %php% and %developer% the meta queries added do %php developer%
What i've seen the most request for is being able to do something like you can on Google where you use quotes to define a specific term wanted, so "php developer" would return ONLY results that match on php developer (sorta how meta queries are handled now, but s queries are not)
May be worth looking at revamping the keyword searches to support modifiers or at a minimum keep things consistent between s and the meta queries generated.
My initial guess would be to pass exact to WP_Query (i think this just tells not to do wildcard % and doesn't split the keywords by spaces) and maybe could do this by checking for quotes around values (strip those out and then set exact on WP_Query)
I've had numerous clients request some functionality enhancement to the keyword searching functionality, mainly around the fact that every word is searched using a LIKE comparison operator so
php developer
would return any results forphp
AND any results fordeveloper
When this is then checked for post meta, a LIKE is generated using
%php developer%
which is a bit inconsistent with how thes
parameter works for searches. So the natives
parameter inWP_Query
does%php%
and%developer%
the meta queries added do%php developer%
What i've seen the most request for is being able to do something like you can on Google where you use quotes to define a specific term wanted, so
"php developer"
would return ONLY results that match onphp developer
(sorta how meta queries are handled now, buts
queries are not)May be worth looking at revamping the keyword searches to support modifiers or at a minimum keep things consistent between
s
and the meta queries generated.My initial guess would be to pass
exact
toWP_Query
(i think this just tells not to do wildcard%
and doesn't split the keywords by spaces) and maybe could do this by checking for quotes around values (strip those out and then setexact
onWP_Query
)