3

I was using the below API to fetch all posts

http://example.com/wp-json/wp/v2/posts/?filter[posts_per_page]=-1

Since the last two days, all of a sudden it stopped working.

For example, the first API used to give me 37 records with 10 records per page, but now it only gives me 10 records instead of 37. It does not return records for rest of the pages. I checked the WordPress site from where I am trying to fetch it, it still has 4 pages and 37 records.

Does anyone has any update if WordPress has changed the API? Below is the path for the API:

http://v2.wp-api.org/reference/posts/

1

1 Answer 1

1

They have modified this filter in the latest 2.0 Beta 14.0 release.
The behavior with the value -1 you're familiar with was in fact a bug.

You should define new parameters in your request.

This link should be interesting: https://github.com/WP-API/WP-API/issues/2357

2
  • I am using per_page instead of the filter. but the problem is per_page value can be between 1 and 100. what if I want to pull records and it is more that 100. per_page will not return records if the count is more than 100. Oct 7, 2016 at 21:55
  • you would need to make multiple requests to fetch all pages. Fetching it in a single request is not possible, and not a good idea. 100 is the maximum because larger numbers of posts lead to degraded performance, memory limit issues, and database load that causes scaling issues ( think how many people can access it at the same time rather than how quickly it loads )
    – Tom J Nowell
    Jun 20, 2021 at 0:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.