2

I have read other posts on this forum and none of which I read are solving my problem.

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

Or even: http://www.example.com/wp-json/wp/v2/posts?filter[posts_per_page]=99

It still returns 10 posts. The same is happening when I try to get the Categories, or the Tags.

I have a request to pull ALL categories, tags, and posts from the REST API as a single list.

2 Answers 2

2

According to the documentation, the correct argument is per_page

7
  • I just tried example.com/wp-json/wp/v2/posts?filter[per_page]=-1 and example.com/wp-json/wp/v2/posts?filter[per_page]=99 with the same results. The reason I'm trying 99 is I heard they might have done away with the -1 param and limited it to 1-100. Just trying things based on what I read. Commented May 18, 2017 at 16:37
  • 1
    Wait! I got it. You're right. example.com/wp-json/wp/v2/posts?per_page=100 works! Without the filter[] Commented May 18, 2017 at 16:39
  • Do you know if there's a way to get it beyond 100? or how I get the next 100? Maybe there's a script for this...? Commented May 18, 2017 at 16:40
  • No way to get around it that I know of. It's for performance reasons. Just make multiple calls using page=1, page=2, etc. It returns a total count of items found so that will tell you how many calls to make.
    – WebElaine
    Commented May 18, 2017 at 22:19
  • 1
    I updated the answer with the resolution to get beyond 100 by using a loop with a page query. Just waiting for approval. Commented May 23, 2017 at 1:29
2

You can only able to retrieve 100 post per page,after that use pagination as Wordpress wpjson post pagination.

Eg : http://example.com/wp-json/wp/v2/posts?per_page=100&page=6

This will fetch the 6th page and which contains 100 post ranging between 500 and 600 posts.

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.