WP Rest API: details of latest post including featured media url in one request?

I’m using wp-rest api to get posts information. I also use wp rest api filter items to filter fields and summarize the result: When I call http://example.com/wp-json/wp/v2/posts?items=id,title,featured_media it returns results like this: [ { “id”: 407, “title”: { “rendered”: “Title 1” }, “featured_media”: 399 }, { “id”: 403, “title”: { “rendered”: “Title 2” }, “featured_media”: … Read more

WordPress Rest API custom endpoint optional param

Is it possible to use register_rest_route() with optional parameters in url? Let’s say route is registered this way: register_rest_route( ‘api’, ‘/animals/(?P<id>\d+)’, [ ‘methods’ => WP_REST_Server::READABLE, ‘callback’ => ‘get_animals’, ‘args’ => [ ‘id’ ], ] ); It’s now possible to perform api call on url like /wp-json/api/animals/15, but is there a way to declare the param … Read more

How to use OAuth authentication with REST API via CURL commands?

I am trying to use the WordPress Rest Api with authentication to get more data from the API. I have installed the Oauth plugin, rest-api plugin, and gotten API credentials from WP-CLI. I have figured out how to access data without authorization. This works: // set our end point $domain = “http://localhost/wp-api”; $endpoint = $domain.”/wp-json/wp/v2/posts/”; … Read more

WordPress 4.7.1 REST API still exposing users

I have upgraded my WordPress to 4.7.1, and after that I’ve tried to enumerate users through REST API, which should be fixed, but I was able to retrieve users. https://mywebsite.com/wp-json/wp/v2/users Output: [{“id”:1,”name”:”admin”,”url”:””,”description”:””,”link”:”https:\/\/mywebsite\/author\/admin\/”,”slug”:”admin”,”avatar_urls”:{“24”: … Changelog from latest version: The REST API exposed user data for all users who had authored a post of a public post … Read more