Linked Questions

Popular Questions

How to get the next set of posts?

Asked by At

I've created a Custom Endpoint and I'd like to fetch the next set of posts, but it's only showing the first 12, how should I get the next set through an URL with a page query?

ex: mysite.test/wp-json/my_cus_post_type_name?page=1

Below is my current progress:

    $pageParam = $request->get_param('page');

    $args = array(
        'post_type' => 'my_cus_post_type_name',
        'post_status' => 'publish',
        'posts_per_page' => 12

    $posts = get_posts($args);

I'm pretty new to this, so any help would be appreciated, thank you!

Related Questions