Reputation: 187
I am trying to display all blog posts - over 100, but only 10 are being shown. i have tried to update the Settings > Reading in WP to show 100 posts, but it does not change the number of posts being shown through frontity. is there a default setting that I am not aware of?
Upvotes: 0
Views: 336
Reputation: 187
Actually I was able to solve this. In the WP functions.php, i added this snippet, and it allows for more than the default 10 posts:
add_filter( 'rest_post_query', 'se35728943_change_post_per_page', 10, 2 );
function se35728943_change_post_per_page( $args, $request ) {
$max = max( (int) $request->get_param( 'custom_per_page' ), 200 );
$args['posts_per_page'] = $max;
return $args;
}
JSON can be seen at /wp-json/wp/v2/posts?custom_per_page
Upvotes: 3