1

I am trying to get the json data of my posts. I have tried with both v1.2.4 and v2 of the REST API plugin.

If I enter

http://example.com/wp-json/posts?type=magazine

or

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

just an empty array is returned.

If I enter

http://example.com/wp-json/posts?type=magazine&filter[posts_per_page]=80

(or any number between 1 and 80)

all data appear just fine.

Is there a limit? I need to get ALL the posts from any custom post type.

2
  • 1
    See this Nov 15, 2015 at 18:32
  • Thank you so much for your reply. It must be that the server runs out of memory then. Do you know what could I do about that?
    – Jeff
    Nov 15, 2015 at 18:36

2 Answers 2

1

Try this instead for pagination. It returns all the posts on my site.

http://example.com/wp-json/wp/v2/posts/?filter[category_name]=country&filter[posts_per_page]=-1
2
  • As enhancement the important part filter[posts_per_page]=-1 without a filter, like /wp-json/posts?filter[posts_per_page]=-1
    – bueltge
    Jan 17, 2018 at 8:53
  • Nope doesn't work, only ever brings back the first 10
    – djack109
    Nov 27, 2022 at 18:57
0

This article has the right answer

How to Pull ALL Posts, Categories, or Tags in WordPress REST API

Turns our the query parameter is /wp-json/wp/v2/products/?per_page=xx

Where xx is the number of posts you want.

I only needed to get twenty so not sure if there is any upper limit

Your Answer

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

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