Powered By Blogger

Thursday, September 13, 2018

call api in same wordpress instance OR WordPress REST API Calls Internally

REF : https://wpscholar.com/blog/internal-wp-rest-api-calls/



$api_data = array(
'post' => $post
);

$request = new WP_REST_Request( 'POST', '/gic/v1/subscriber' );
$request->set_query_params( $api_data );
$response = rest_do_request( $request );
$server = rest_get_server();
$data = $server->response_to_data( $response, false );
$json = wp_json_encode( $data );

No comments:

Post a Comment