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?
I actually solved this for anyone else that comes across this problem. 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
1 Like
Hi @meaghan1
Glad to see you were able to solve your problem
Very elegant solution! Thanks for sharing it with the community