Raise the REST API's 100-item limit for one post type, so a script or app can fetch more items in a single request.
add_filter( 'rest_post_collection_params', function ( array $params ): array {
if ( isset( $params['per_page'] ) ) {
$params['per_page']['maximum'] = 250;
}
return $params;
} );
Always add PHP to a staging site first, or have FTP or file manager access ready, so you can undo it if something goes wrong.
The REST API returns at most 100 items per page. For exports, sync scripts or static site builds, paging through hundreds of requests is slow. This snippet raises the limit for posts.
Every collection endpoint defines its query parameters, including per_page with a maximum of 100. The rest_post_collection_params filter changes that maximum for posts. Requests with ?per_page=250 then work instead of returning an error.
rest_page_collection_params for pages, rest_product_collection_params for a product post type.X-WP-TotalPages is usually the better long-term solution.Request /wp-json/wp/v2/posts?per_page=250. It should return posts instead of a “per_page must be between 1 (inclusive) and 100” error.