[wp-hackers] Search in given taxonomy term

Patrik Bóna patrik.bona at mrhead.sk
Fri Sep 10 10:59:34 UTC 2010

I have opened ticket for this issue:


And if anyone is interested, this is my workaround:

function gb_search_join($join, $wp_query) {
     global $wpdb, $lang;

     if(!$wp_query->is_tax && is_search()) {
         $join .= " JOIN $wpdb->term_relationships tr1 ON 
($wpdb->posts.ID = tr1.object_ID)
                 JOIN $wpdb->term_taxonomy tt1 ON (tr1.term_taxonomy_id 
= tt1.term_taxonomy_id)
                 JOIN $wpdb->terms t1 ON (tt1.term_id = t1.term_id AND 
tt1.taxonomy = 'jazyk' AND t1.slug = '$lang')";

     return $join;
add_filter('posts_join', 'gb_search_join', 10, 2);

The reason why i am checking $wp_query->is_tax is that when this bug 
will be fixed, then is_tax should be set to true in search & taxonomy 
query and then JOIN will be not modified. So i don't need to change code 
when client will upgrade his WP installation.  I hope i am right ;).


On 09/08/2010 02:21 PM, scribu wrote:
> On Wed, Sep 8, 2010 at 2:43 PM, Patrik Bóna<patrik.bona at mrhead.sk>  wrote:
>> For example:
>> query_posts("taxonomy=jazyk&term=sk&s=word');
>> in this case taxonomy and term are ignored a everything containing 'word'
>> is returned...
>> And it is also same if i type these parameters to url without
>> query_posts...
> I see. That's a bug. You should open a ticket in trac.

More information about the wp-hackers mailing list