Skip to content

Instantly share code, notes, and snippets.

@johnlewisdesign
Created June 18, 2020 19:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save johnlewisdesign/762ebf7cf7f3826a86366d28dc49347d to your computer and use it in GitHub Desktop.
Save johnlewisdesign/762ebf7cf7f3826a86366d28dc49347d to your computer and use it in GitHub Desktop.
Stack WP/WooCommerce API calls to override 100 limit
header('Access-Control-Allow-Origin: *', 'Content-Type: application/json'); // Avoid cross origin block
$url1 = 'https://www.example.com/wp/v2/posts?per_page=100&page=1'; // path to your JSON file
$url2 = ''https://www.example.com/wp/v2/posts?per_page=100&page=2'; // path to your JSON file
$json1 = file_get_contents($url1);
$json2 = file_get_contents($url2);
$my_array1 = json_decode($json1, true);
$my_array2 = json_decode($json2, true);
$res = array_merge($my_array1, $my_array2);
$json_merge = json_encode($res);
echo $json_merge; // new json
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment