douchun1961 2019-05-28 21:58
浏览 90

使用'categories'参数总会产生WordPress Rest API错误,“rest_post_invalid_page_number”?

I am working on a web app in PHP that must display recent blog posts of a specific category from a separate WordPress site. We are accessing these posts via the REST API. When I use the categories argument, I get a 400 error. Without the categories argument (and with all other endpoints I've tried), I get a successful response.

  • The posts are being requested from a site running WordPress 5.2.1.
  • For now, I am just accessing the endpoints via my browser, and viewing the JSON returned there.
  • I am using the endpoint: https://itherapy.com/wp-json/wp/v2/posts?categories=60.
  • There are 43 published / public posts in the posts category with the id of 60.
  • Even if I specify the additional arguments of per_page and page (for example, like https://itherapy.com/wp-json/wp/v2/posts?categories=60&per_page=1&page=1), I get the same error. By removing the categories argument (like this: https://itherapy.com/wp-json/wp/v2/posts?per_page=2&page=2), the other arguments work (ie, I get 2 posts, offset by 2 posts), but this is for ALL posts. That is expected, but why might the categories argument be breaking my request?

I can submit similar requests to the WordPress Rest API demo site, like so: https://demo.wp-api.org/wp-json/wp/v2/posts?categories=11, and all of the posts from category 11 are returned. the same request made from my domain fails.

The endpoint I am trying to access data from is:

https://itherapy.com/wp-json/wp/v2/posts?categories=60

The error message I am getting back is:

{
  "code": "rest_post_invalid_page_number",
  "message": "The page number requested is larger than the number of pages available.",
  "data": {
    "status": 400
  }
}
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 使用C#,asp.net读取Excel文件并保存到Oracle数据库
    • ¥15 C# datagridview 单元格显示进度及值
    • ¥15 thinkphp6配合social login单点登录问题
    • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
    • ¥15 如何在scanpy上做差异基因和通路富集?
    • ¥20 关于#硬件工程#的问题,请各位专家解答!
    • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
    • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
    • ¥30 虚心请教几个问题,小生先有礼了
    • ¥30 截图中的mathematics程序转换成matlab