[wp-trac] [WordPress Trac] #19705: better taxonomy query URL syntax

WordPress Trac wp-trac at lists.automattic.com
Sun Jan 1 00:30:37 UTC 2012


#19705: better taxonomy query URL syntax
--------------------------+-----------------------------
 Reporter:  misterbisson  |      Owner:
     Type:  enhancement   |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Query         |    Version:  3.3
 Severity:  normal        |   Keywords:  has-patch
--------------------------+-----------------------------
 Problem: WP's native taxonomy URL syntax supports logical OR/IN and AND
 operations, but not NOT IN. Blog post with more rambling:
 http://maisonbisson.com/blog/post/16074/better-taxonomy-query-syntax/ .

 Solution: the attached patch extends the URL syntax to support these
 logical operators.

 - Taxonomy terms are separated by commas (it preserves support for the old
 +separated syntax).

 - Terms prepended with a + are required (AND)

 - Terms prepended with a - are excluded (NOT IN)

 - All other terms are simply IN

 Examples:

 - http://site.org/tag/term-one,term-two/ : posts containing one or more of
 the named terms

 - http://site.org/tag/+term-one,+term-two/ : posts containing both of the
 named terms

 - http://site.org/tag/term-one,-term-two/ : posts containing term-one, but
 excluding term-two

 Working examples (at least until I revert my site):

 - http://maisonbisson.com/blog/post/tag/wordpress,+mysql/ : IN and AND
 syntax (it's an accident of how the query is handled internally that it
 doesn't require a + to be AND'd in this case)

 - http://maisonbisson.com/blog/post/tag/wordpress+mysql/ : old-style AND
 syntax

 - http://maisonbisson.com/blog/post/tag/wordpress,mysql/ : IN syntax

 - http://maisonbisson.com/blog/post/tag/wordpress,-mysql/ : NOT IN syntax
 for the second term

 - http://maisonbisson.com/blog/post/tag/-wordpress,+mysql/ : NOT IN the
 first term, AND the second term

 About the patch:

 The patch disables the special handling of tags. This is just to narrow
 the scope of work necessary to demonstrate a working patch.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/19705>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list