I am new to the REST api (working with WordPress) and have a question I am hoping someone can answer. First off here is my SUPER basic code example:
$response = wp_remote_get( esc_url( home_url( '/' ) ).'/wp-json/wp/v2/posts?filter[posts_per_page]=5' );
if( is_wp_error( $response ) ) {
return;
}
$posts = json_decode( wp_remote_retrieve_body( $response ) );
foreach ($posts as $post){
echo $post->title->rendered;
echo $post->content->rendered;
}
As you can see I am using the filter:
?filter[posts_per_page]=5
What I am trying to accomplish is as follows. On the page where the person is reading the first 5 posts I would have a button that says, load more. On clicking load more I would load 5 more posts.
Am I way off base with this or am I just missing this by a little bit.
Thanks so much!