[wp-hackers] did I stumble across a bug?

Paul paul at codehooligans.com
Tue Apr 26 19:12:03 UTC 2011


On Apr 26, 2011, at 3:05 PM, Foolish Visions wrote:

>>> Then you could always try sending category__in or category__and instead of cat<<
> 
> Thanks Jonathon - but using category__in or category__and makes it ignore *all* the categories, and acts like it's not even there.
> 
> I read somewhere recently that this was a little-known bug - that WP wouldn't recognize multiple categories in search anymore, but for the life of me I can't find where I read it.  But no matter how hard I search for it again, all I come up with is that "cat" *should* work with comma-separated values. But it just searches the first and ignores the rest. Even if I manually type in the categories to search, it still ignores all ID's but the first one.

Well first suggestion is to try debugging this via your search.php template. Dump the $wp_query. Check to see it the categories are being set. Also, might want to try adding this via a filter. Inside that function you should be able to grab you form variable and make sure it uses your search terms. Of course per other suggestions you can change the 'cat' to 

function mySearchFilter($query) 
{
   if ($query->is_search)
   {
      $query->set('cat','1,2,3');
   }
   return $query;
}
add_filter('pre_get_posts','mySearchFilter');

http://codex.wordpress.org/Custom_Queries



More information about the wp-hackers mailing list