Skip to content

Instantly share code, notes, and snippets.

View andreilupu's full-sized avatar
⌨️
Hitting keys

Andrei Lupu andreilupu

⌨️
Hitting keys
View GitHub Profile
@andreilupu
andreilupu / WordPress Paginated API results
Last active October 26, 2016 13:33
How to loop the API results which are paginated
<?php
/**
* Let's imagine that we need the issues number from an github organization
* The issues API results are limited to 100 per page so we need to call this recursively
* $offset (int) = the number of pages to skip for the current request
*/
function request_issues_number( $offset = 0 ) {
$page = 1;
if ( ! empty( $offset ) ) {