[wp-trac] [WordPress Trac] #9951: Add [taxonomy]__in,
[taxonomy]__not_in to wp_query
WordPress Trac
wp-trac at lists.automattic.com
Wed May 27 18:39:19 GMT 2009
#9951: Add [taxonomy]__in, [taxonomy]__not_in to wp_query
-------------------------+--------------------------------------------------
Reporter: joehoyle | Owner: filosofo
Type: enhancement | Status: new
Priority: high | Milestone: 2.8
Component: Taxonomy | Version: 2.8
Severity: normal | Keywords:
-------------------------+--------------------------------------------------
Currently it's not possible to query for multiple custom taxonomy terms
using query_posts the same way you can do tag__in, category__in,
tag__not_in etc. I propose wp_query is extended to support querying by
multiple custom taxonomy terms and also multiple custom taxonomies and
terms.
For example, to get all posts that are in my 'Microsoft' term in the
'company' tax:
{{{
query_posts( array( 'company__in' => array( 5 ) ) ) //5 is the term_id for
Microsoft
}}}
Multiple taxs with multiple terms:
{{{
query_posts( array(
'company__in' => array( 5, 10 ),
'people__in' => array( 11, 12, 13 ),
));
}}}
Basically: [tax]__in, [tax]__not_in and [tax]__slug_in should all work, in
conjunction with tag__in etc.
I have written a patch that implements this, currently [tax]__in,
[tax]__not_in, but [tax]__slug_in will be an easy addition.
As tag__in, category__in and all of those are no different, the patched
lines I wrote could replace all those hardcoded statements fairly easily.
--
Ticket URL: <http://core.trac.wordpress.org/ticket/9951>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list