【问题标题】:WP rest api v2 posts filter by 'search' & 'category_name' not workingWP rest api v2 帖子按“搜索”和“类别名称”过滤不起作用
【发布时间】:2016-12-09 05:24:18
【问题描述】:

我将 api 称为http://examples.com/wp-json/wp/v2/posts?filter[category_name]=uncategorize&per_page=30&order=asc&search=hello

我无法从该特定类别中获得特定帖子。 我得到了所有类别的所有结果。请有任何建议。

【问题讨论】:

  • 你用的是内置的WP4.7吗?还是插件?
  • 我正在使用 WP REST API v2.0 插件

标签: wordpress rest api plugins


【解决方案1】:

自 WordPress 4.7 起,任何 post 端点的过滤器参数都已删除。顺便说一句,WP API Repo 有一个用于这项工作的插件“Rest Filter”:

https://github.com/WP-API/rest-filter

【讨论】:

  • 显然,即使安装了 rest-filter 插件,同时使用 ?search 或 ?filter[s] 也会导致 api 返回任何帖子(例如 post_type 设置为 'any')。有什么想法吗?
猜你喜欢
  • 1970-01-01
  • 2018-01-29
  • 1970-01-01
  • 2021-10-12
  • 1970-01-01
  • 2018-02-17
  • 2014-11-07
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多