TM

WP REST API

WordPress

  • publishing
  • content management

About WP REST

The WordPress REST API provides programmatic access to your WordPress site, allowing you to manage and publish site content. You can access the content of your site with the same authentication restrictions. The API enables the block editor, as well as modern plugin interfaces, without compromising privacy or security.

Discussions1

  • Setting the `_embed` param on the request object won’t work. `$request` `= new` `WP_REST_Request( 'GET', '/wp/v2/posts'` `);` `$request->set_param( '_embed', 1 );` `$response` `= rest_do_request( $request` `);` Instead, manually call the [`WP_REST_Server::response_to_data`](https://developer.wordpress.org/reference/classes/wp_rest_server/) function. `$request` `= new` `WP_REST_Request( 'GET', '/wp/v2/posts'` `);` `$response` `= rest_do_request( $request` `);` `$data` `= rest_get_server()->response_to_data( $response, true );` `var_dump( $data['_embedded'] );`

Documentation

TM

Copyright © Hoss Technologies, Inc. 2020 - All rights reserved. Terms of Service & Privacy Policy