[wp-trac] [WordPress Trac] #41287: Getting posts that belong to multiple tags or categories

WordPress Trac noreply at wordpress.org
Tue Jul 11 13:35:24 UTC 2017


#41287: Getting posts that belong to multiple tags or categories
--------------------------+------------------------------
 Reporter:  sebbb         |       Owner:
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  REST API      |     Version:  4.8
 Severity:  normal        |  Resolution:
 Keywords:                |     Focuses:
--------------------------+------------------------------

Comment (by kadamwhite):

 > It looks like behind the scenes the API uses an OR logic instead of the
 correct AND logic.

 Unfortunately this is exactly what is happening; the API does not
 currently support AND logic for querying records by taxonomy ID. We
 tracked this problem in our old [https://github.com/WP-API/WP-
 API/issues/2768 GitHub repository as issue # 2768], but it doesn't look
 like that issue has made it here into trac -- thanks for opening the
 ticket.

 We should have a way to query posts by taxonomy terms using an AND
 relation. I agree that the current behavior is highly unintuitive.

 @rmccue may be able to clarify but I'd also comment that, as far as I
 understand it, `id1+id2` or `id1,id2` are both just proxies for the
 `?tags=id1&tags=id2` syntax, so there isn't a clear way to distinguish
 between AND or OR without introducing a new API query parameter.

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


More information about the wp-trac mailing list