Pagination returns 404 after page 20

What you are experiencing is quite normal and expected. This is one of the big reasons I always hammer on this point, never use custom queries to replace the main query on the home page or any type of archive page. They solve one issue but creates plenty other new ones Lets look at what … Read more

WP_Query offset argument does not work

The offset index for WP_Query generally works with pagination. When you set pagination to a -1 the function assumes you’re getting all posts and there will be no pagination or offset. So to counteract this you would set the posts_per_page to a high number like 999. Reading the Function Reference on WP_Query the pagination section … Read more

WP_Query result in form of Rest API results

I think we can simplify it with: $request = new WP_REST_Request( ‘GET’, ‘/wp/v2/posts’ ); $response = rest_do_request( $request ); $data = rest_get_server()->response_to_data( $response, true ); by using rest_do_request().

tech