Skip to content

Instantly share code, notes, and snippets.

@obiPlabon
Created April 6, 2019 08:32
Show Gist options
  • Save obiPlabon/63beae2855583a9feaac26108d2da2d9 to your computer and use it in GitHub Desktop.
Save obiPlabon/63beae2855583a9feaac26108d2da2d9 to your computer and use it in GitHub Desktop.
<?php
$request = new WP_REST_Request( 'GET', '/wp/v2/posts' );
$request->set_query_params( [ 'per_page' => 12 ] );
$response = rest_do_request( $request );
$server = rest_get_server();
$data = $server->response_to_data( $response, false );
$json = wp_json_encode( $data );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment