Skip to content
This repository has been archived by the owner. It is now read-only.

How to increase per_page limit to 200 ? #2914

Closed
Amenocy opened this issue Nov 13, 2016 · 6 comments

Comments

@Amenocy
Copy link

commented Nov 13, 2016

hi
can i increase per_page limit to 200 using actions ?

@shazzygh

This comment has been minimized.

Copy link

commented Dec 6, 2016

I would also be interested in this!

@beatelite

This comment has been minimized.

Copy link

commented Dec 6, 2016

Not sure about this but you can do it via a param in the request

wp-json/wp/v2/posts/?page=1&per_page=200

@maplethorpej

This comment has been minimized.

Copy link

commented Dec 6, 2016

I believe you'd need to actually modify the query within the plugin itself to increase results per request.

@Amenocy

This comment has been minimized.

Copy link
Author

commented Dec 7, 2016

this limit is hard coded . please developers add 2 options
1 - remove some things from output (whiteout coding ! )
2- add some useful hooks

@BE-Webdesign

This comment has been minimized.

Copy link
Member

commented Dec 10, 2016

Hi @Amenocy,

Thank you for using the WP REST API. If you are on WordPress 4.7, it is possible to modify the default posts per page, though it is not recommended. The following code snippet will change the collection arguments for the basic posts endpoint. To handle every post type either loop through them or handle them individually.

add_filter( 'rest_post_collection_params', 'my_prefix_change_post_per_page', 10, 1 );

function my_prefix_change_post_per_page( $params ) {
    if ( isset( $params['per_page'] ) ) {
        $params['per_page']['maximum'] = 200
    }

    return $params;
}

Didn't test it but that should work.

@nylen nylen closed this Jan 5, 2017

@nylen

This comment has been minimized.

Copy link
Member

commented Jan 5, 2017

Now that the REST API has been merged into WordPress core, development and support are no longer taking place in this repository.

If you're still having this issue, please post a support request to the WordPress forums at https://wordpress.org/support/forum/how-to-and-troubleshooting/ with the topic tag "rest-api".

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
6 participants
You can’t perform that action at this time.