When to check for max_num_pages using WordPress REST API?
pre_get_posts does fire for REST requests. After copying your function and stepping through it, your code is actually working — the first time. However the WP REST controller has the following bit: if ( $total_posts < 1 ) { // Out-of-bounds, run the query again without LIMIT for total count. unset( $query_args[‘paged’] ); $count_query = … Read more