Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save andreasottosson/f6ddfcd5f3ed9ca7c8cf0aa3fce85cdb to your computer and use it in GitHub Desktop.
Save andreasottosson/f6ddfcd5f3ed9ca7c8cf0aa3fce85cdb to your computer and use it in GitHub Desktop.
Show more than 100 hits in WP REST API (Wordpress)
// Make REST API show more than 100 results
add_action( 'rest_forhandlere_query', 'forhandlere_override_per_page' );
/*
* params is the query array passed to WP_Query
*/
function forhandlere_override_per_page( $params ) {
if ( isset( $params ) AND isset( $params[ 'posts_per_page' ] ) ) {
$params[ 'posts_per_page' ] = 500;
}
return $params;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment