[wp-trac] [WordPress Trac] #12891: Advanced multi-taxonomy WP_Query()s

WordPress Trac wp-trac at lists.automattic.com
Mon Nov 22 21:24:16 UTC 2010


#12891: Advanced multi-taxonomy WP_Query()s
----------------------------+-----------------------------------------------
 Reporter:  markjaquith     |       Owner:  markjaquith    
     Type:  task (blessed)  |      Status:  assigned       
 Priority:  normal          |   Milestone:  3.1            
Component:  Query           |     Version:  3.0.1          
 Severity:  normal          |    Keywords:  ongoing-project
----------------------------+-----------------------------------------------

Comment(by Otto42):

 After talking to scribu and nacin, here's a patch to allow a global OR in
 the tax_query parameter. It works like this:

 {{{
 query_posts(array(
         'tax_query' => array(
                 'relation' => 'OR',
                 array(
                         'taxonomy' => 'post_format',
                         'terms' => array('post-format-gallery'),
                         'field' => 'slug',
                 ),
                 array(
                         'taxonomy' => 'category',
                         'terms' => array('gallery'),
                         'field' => 'slug',
                 ),
         ),
 ) );
 }}}

 The relation=>OR changes the tax_query to use OR's instead of AND's on the
 relevant WHERE clauses. So the above query will show any post with
 category of gallery or a post format of gallery.

 Patch is relation-or.diff, against current trunk.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/12891#comment:168>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list