I’m building a plugin for a client and it requires me to use wp_remote_get to retrieve records from their server.
I have everything working but I can’t seem to find any good examples of how you add pagination to a remote request.
This is what I’m doing:
$response = wp_remote_get( ‘http://somedomain.com/my/api/route’ );
$body = wp_remote_retrieve_body( $response );
$decoded_body = json_decode( $body, true );
//code to loop through decoded body
I’m assuming that there is some argument like per_page that can be used in the call to wp_remote_get but I’ve tried it and it hasn’t worked as far as I can see.
Further, when I have the number of records per page, How do I go and implement the actual pagination functionality?
If anybody has any experience with doing this or has any links to working examples, I would be very thankful.
Read more here:: add pagination to wp_remote_get