[wp-hackers] Custom Taxonomy Query - Select posts with a taxonomy AND none

Nathaniel Taintor goldenapplesdesign at gmail.com
Tue Mar 26 19:20:03 UTC 2013


Brings up an interesting point - why doesn't tax_query have a NOT EXISTS
operator, the same way that meta_query does?  A quick search of trac didn't
show any discussion of the issue - has it been discussed and rejected?

I've hand-rolled the SQL for that sort of query myself before, and it seems
like a common need. The SQL necessary for such a query might be ugly,
complex, and slow, and probably not the best thing to promote. But it seems
better to have an API available for it than to recommend that people store
this kind of meta-taxonomy data in taxonomy terms.

Nathaniel Taintor, Designer/Developer
*Golden Apples Design*
http://goldenapplesdesign.com

@GoldenApples | 717.434.3226
goldenapplesdesign at gmail.com


On Tue, Mar 26, 2013 at 3:30 AM, John Blackbourn
<johnbillion+wp at gmail.com>wrote:

> On 26 March 2013 09:47, Mike Little <wordpress at zed1.com> wrote:
> > Add terms to your custom taxonomies for "All Segments" and "All Price
> > Bands".
> >
> > Assign those to the appropriate CPT's
> >
> > Then always add "All segments" to segment search terms, and "all price
> > bands" to price band search terms.
> >
> > That will achieve the results you want with exactly the method you are
> > using now.
> >
> > Mike
>
> This is how I've achieved this in the past. Definitely the most
> straight forward method, otherwise you'll need to write the SQL for
> such a query.
>
> John
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>


More information about the wp-hackers mailing list