Domanda

I want to develop an app for my WordPress.org website. I am using wp rest api to receive post in json. My question is how do I retrieve posts page by page. For example if there are 50 posts I want to receive 1-10 then 11-20 and so on.

È stato utile?

Soluzione

Well, you can add ?page={$page_number} to the URL that you're requesting.

See, for example, http://demo.wp-api.org/wp-json/wp/v2/posts/?page=2.

It appears to split the posts into pages of 10.

Reference

  • WP-API documentation (I found this in the docs for v1 of the API, but per the sample URL above, it works on v2 as well)
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a wordpress.stackexchange
scroll top