首页 > 解决方案 > tax_relation=OR 不适用于自定义帖子类型和多个自定义分类法(REST API 5.4)?

问题描述

/wp/v2/mycustompost?&_fields=id,title&custom-tax-1=1&custom-tax-2=2

上面的 URL 按预期工作,只返回 custom-tax-1 ID: 1 和 custom-tax-2 ID: 2 的帖子

/wp/v2/mycustompost?&_fields=id,title&custom-tax-1=1&custom-tax-2=2&tax_relation=OR

上面的 URL 返回所有帖子(包括没有分类的帖子),而不是 custom-tax-1 ID: 1 或 custom-tax-2 ID:2 的帖子

据此:https ://make.wordpress.org/core/2020/02/29/rest-api-changes-in-5-4/它应该可以正常工作吗?

例如,在 WordPress 5.4 中,帖子端点查询 /wp/v2/posts?tags=1&categories=2&tax_relation=OR 现在将返回标签 ID 1 或 ID 2 类别中的帖子。

标签: wordpresswordpress-rest-api

解决方案


推荐阅读