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
Closed

How to increase per_page limit to 200 ? #2914

Amenocy opened this issue Nov 13, 2016 · 6 comments

Comments

@Amenocy
Copy link

@Amenocy Amenocy commented Nov 13, 2016

hi
can i increase per_page limit to 200 using actions ?

@shazzygh
Copy link

@shazzygh shazzygh commented Dec 6, 2016

I would also be interested in this!

Loading

@beatelite
Copy link

@beatelite beatelite 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

Loading

@maplethorpej
Copy link

@maplethorpej maplethorpej commented Dec 6, 2016

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

Loading

@Amenocy
Copy link
Author

@Amenocy Amenocy 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

Loading

@BE-Webdesign
Copy link
Member

@BE-Webdesign BE-Webdesign 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.

Loading

@nylen nylen closed this Jan 5, 2017
@nylen
Copy link
Member

@nylen nylen 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".

Loading

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
6 participants