# Raise the REST API per_page Limit

> Lets REST API requests for posts and pages ask for more than 100 items at once, useful for exports and static site generators.

- Type: PHP
- Runs: Run everywhere
- Category: [Developer](https://wpide.com/library/category/developer/)
- Tags: rest-api, api, pagination, headless
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/dev-rest-max-per-page/

## Code

```php
$wpide_rest_max = 500; // Highest per_page value allowed.

foreach ( array( 'post', 'page' ) as $wpide_rest_type ) {
    add_filter( "rest_{$wpide_rest_type}_collection_params", function ( $params ) use ( $wpide_rest_max ) {
        if ( isset( $params['per_page'] ) ) {
            $params['per_page']['maximum'] = $wpide_rest_max;
        }

        return $params;
    } );
}
```

## Notes

Large values make heavy queries; keep $max reasonable.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Raise the REST API per_page Limit" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
