[wp-hackers] boolean logic with tag and categorie url params?

Bjorn Wijers burobjorn at gmail.com
Tue Jun 21 20:23:24 UTC 2011


I've been (re)evaluating WordPress' ability to query post using _only_
the tag and category parameters for a project of mine. It's been a while
using this (roughly 3 years according to ticket #5433) and I wondered
what the current state would be.

Thus far my conclusion is that it's a lot better then it used to be,
however there seems no support to be for a combination of boolean AND
with an boolean OR unless using a combination of categories and tags is
used. So I cannot force the query to do something like: 'give me all
posts with tag1 and tag2 and either tag3 or tag4'. Is this correct?

Here are some examples of the urls I tested (trying to write a coherent
blog post on this..)

1. domain.ext/blogname/?tag=tag1+tag2
Shows only posts with both tags

2. domain.ext/blogname/?tag=tag1+tag2,tag3
Shows all posts tagged with one or more of these tags tag1, tag2, or
tag3. It does NOT show the posts with at least tag1 and then either tag2
or tag3 (or both).

3. domain.ext/blogname/?category_name=Category2&tag=tag1+tag2
Shows only posts in Category2 tagged with both tag1 and tag2

4. domain.ext/blogname/?category_name=Category2,Category1&tag=tag1+tag2
Shows posts in one or both categories as long as the post has been
tagged with both tags

Ps: Is there more documentation on the url parameters in relation to
querying? I tried the Codex, but I might have missed something?


More information about the wp-hackers mailing list