WP Rest API – How to get an empty response if query has no posts
I found my answer in WP_REST_Posts_Controller class /* * If we intersected, but there are no post ids in common, * WP_Query won’t return “no posts” for post__in = array() * so we have to fake it a bit. */ if ( ! $args[‘post__in’] ) { $args[‘post__in’] = array( 0 ); }