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

Alex Hempton-Smith hempsworth at gmail.com
Tue Mar 26 09:02:01 UTC 2013


There's not really a code snippet to post. Perhaps I can phrase it
differently; can I have WP_Query return posts which match the taxonomy term
searched for (usual behaviour), and posts which have NO terms for that
given taxonomy?

So if I search for 'foobar' it would return posts where $mytax == 'foobar'
and $mytax == '' (empty)

Alex


On Tue, Mar 26, 2013 at 2:55 AM, Mike Schinkel <mike at newclarity.net> wrote:

> Hi Alex,
>
> Maybe post your code snippet that is not working the way you want?  Might
> be easier to help that way...
>
> -Mike
>
> On Mar 25, 2013, at 9:30 PM, Alex Hempton-Smith <hempsworth at gmail.com>
> wrote:
>
> > Hi all,
> >
> > I have a CPT with three taxonomies:
> >
> >   - Segment
> >   - Price Band
> >   - Descriptive Tag
> >
> > Most posts would have one of the above assigned to them, but some posts
> > might be relevant for ALL segments, or ALL price bands, so they don't
> have
> > ANY specified.
> >
> > How do I include posts in EVERY WP_Query if there is NO segment/price
> band
> > specified?
> >
> > For example, if I search for:
> >
> >   - Segment = X
> >   - Price Band = Y,Z,A
> >   - Descriptive Tags = B,C,D
> >
> > I get all posts that match X,Y,Z,A,B,C and D. But I'd like all posts with
> > NO segment/price band to ALSO be included in this result. As they are
> > assumed if they have nothing specified, they are relevant to ALL
> searches.
> >
> > Does this make sense?
> >
> > Thanks for your patience as I try to describe what I'm trying to achieve!
> >
> > Alex
> > _______________________________________________
> > wp-hackers mailing list
> > wp-hackers at lists.automattic.com
> > http://lists.automattic.com/mailman/listinfo/wp-hackers
>
> _______________________________________________
> 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