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?
Asked
Active
Viewed 300 times
0
-
No, there's not. But maybe the theme does ignore the setting from the backend and is set to a fixed amount of 10 posts. Does the behaviour change if you have less than 10 posts or something like 20? – flomei Aug 27 '20 at 08:03
1 Answers
2
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

kb_
- 177
- 2
- 21