Isn’t rest_do_request() filtered by pre_get_posts() filter?
Removing the conditionals for the set() calls will solve the problem. I suspect that the REST request is populating those parameters, and as such the set() calls do not occur. Untested: add_action( ‘pre_get_posts’, ‘test_pre_get_post_filter’ ); function test_pre_get_post_filter( $query ) { if ( is_admin() ) { return; } $query->set( ‘post_status’, array( ‘publish’ ) ); $query->set( ‘posts_per_page’, … Read more