Add [taxonomy]__in, [taxonomy]__not_in to wp_query
|Reported by:||joehoyle||Owned by:||MarkJaquith|
Description (last modified by scribu)
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.
Change History (31)
- Keywords needs-patch added; has-patch removed
- Milestone changed from 2.9 to Future Release
- Priority changed from high to normal
comment:12 willmot — 4 years ago
- Priority changed from normal to high
comment:15 in reply to: ↑ 3 ; follow-up: ↓ 16 scribu — 4 years ago
- Component changed from Taxonomy to Query
- Keywords needs-patch added; has-patch needs-review tested removed
- Milestone changed from Future Release to 3.0
- Owner changed from filosofo to ryan
comment:18 nacin — 4 years ago
- Milestone changed from 3.0 to Future Release
- Owner changed from ryan to MarkJaquith
- Status changed from new to assigned