[wp-trac] [WordPress Trac] #41287: Add AND query mode for taxonomy terms (was: Getting posts that belong to multiple tags or categories)

WordPress Trac noreply at wordpress.org
Wed Jul 12 09:49:02 UTC 2017


#41287: Add AND query mode for taxonomy terms
------------------------------------------+-----------------------------
 Reporter:  sebbb                         |       Owner:
     Type:  enhancement                   |      Status:  new
 Priority:  normal                        |   Milestone:  Future Release
Component:  REST API                      |     Version:  4.8
 Severity:  normal                        |  Resolution:
 Keywords:  needs-patch needs-unit-tests  |     Focuses:
------------------------------------------+-----------------------------
Changes (by jnylen0):

 * keywords:   => needs-patch needs-unit-tests
 * type:  defect (bug) => enhancement
 * milestone:  Awaiting Review => Future Release


Comment:

 This is intended behavior, not a bug.  I would expect "filter the posts
 list to posts that include tags 41,50" to return all posts that match any
 of these tags.  "exclude tags 41,50" should not match any of those posts.
 If `tags` used AND, but `exclude_tags` used OR, this would be less
 consistent.

 Having said that, adding an AND query mode would be a nice enhancement.
 The solution will likely look similar to the approach discussed in #39494.

 For now, it should be possible to use the `rest_{$this->post_type}_query`
 [filter https://developer.wordpress.org/reference/hooks/rest_this-
 post_type_query/] combined with `register_rest_field` ([docs
 https://developer.wordpress.org/rest-api/extending-the-rest-api/modifying-
 responses/]) to make this functionality work in a plugin.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/41287#comment:5>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list