Last active
July 8, 2019 07:28
-
-
Save mklasen/0ca7632a7a4c7e22fb9834eaa1232feb to your computer and use it in GitHub Desktop.
Increases the maximum results that are returned by the WordPress Rest API
This file contains hidden or 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
<?php | |
class Sample { | |
public function __construct() { | |
$this->hooks(); | |
} | |
private function hooks() { | |
add_filter( 'rest_post_collection_params', [ $this, 'increase_maximum_rest_posts' ] ); | |
} | |
private function increase_maximum_rest_posts( $params ) { | |
if ( isset( $params ) && isset( $params['per_page'] ) ) { | |
$params['per_page']['maximum'] = PHP_INT_MAX; | |
} | |
return $params; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment