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.
https://itherapy.com/wp-json/wp/v2/posts?categories=60
.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
}
}