Created
June 18, 2020 19:22
-
-
Save johnlewisdesign/762ebf7cf7f3826a86366d28dc49347d to your computer and use it in GitHub Desktop.
Stack WP/WooCommerce API calls to override 100 limit
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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