Skip to content

Instantly share code, notes, and snippets.

@mklasen
Last active July 8, 2019 07:28
Show Gist options
  • Save mklasen/0ca7632a7a4c7e22fb9834eaa1232feb to your computer and use it in GitHub Desktop.
Save mklasen/0ca7632a7a4c7e22fb9834eaa1232feb to your computer and use it in GitHub Desktop.
Increases the maximum results that are returned by the WordPress Rest API
<?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