I am using the following to get posts
http://demo.wp-api.org/wp-json/wp/v2/posts
I the max limit on posts is 100 per request.
So I would have to make multiple requests to get all posts.
How can I get the total post count so I know how many requests I have to make?
Thanks.
The response headers include this data:
To determine how many pages of data are available, the API returns two header fields with every paginated response:
X-WP-Total: the total number of records in the collectionX-WP-TotalPages: the total number of pages encompassing all available recordsBy inspecting these header fields you can determine how much more data is available within the API.
via https://developer.wordpress.org/rest-api/using-the-rest-api/pagination/
also for reference: https://wordpress.stackexchange.com/a/250589
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With