Enable pagination for the XML-RPC getRecentPosts function
|Reported by:||feedfabrik||Owned by:|
|Cc:||josephscott, feedfabrik, max@…|
To retrieve posts via the XML-RPC API, currently the following methods can be called:
In changeset r16256 these methods were enhanced to support an optional number of posts. However, the query still always starts from the most recent post and there is no way to retrieve older posts without increasing the optional number of posts to a sufficiently large number and retrieving everything before as well. This can place an unnecessary and unwanted burden on the server.
There is an alternative of requesting a post by ID but for this the ID needs to be known in advance. Until ticket #6850 is addressed, there is no way to query for specific IDs.
I would like to suggest an enhancement that leverages r16256 and introduces another optional parameter for offset.
As an example, the code for blogger_getRecentPosts would get an additional:
if ( isset( $args ) ) $query['offset'] = absint( $args );
That should be enough to get wp_get_recent_posts from post.php do the job.
On more general terms, a new XML-RPC method wp.getPosts could be introduced that simply accepts the array used in wp_get_recent_posts for even more flexibility, but that's probably stuff for another ticket.