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().

Leave a Comment

tech