Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How To Specify the fields to Wordpress API v2

I'm using the WordPress REST API in my project and sending a GET request to:

http://myblog/wp-json/wp/v2/posts  

and It's working quite alright but I want to specify the fields though I don't know how. I have looked at the documentation and still don't know how to go about it. For example, using the public API:

https://public-api.wordpress.com/rest/v1.1/sites/www.mysite.com/posts?number=100&fields=title,excerpt,featured_image 

returns only the specified fields. How do I this with the v2 API?

like image 925
Faraday Avatar asked Mar 31 '16 17:03

Faraday


1 Answers

Here's how to access the a list of titles and excerpts using REST API v2:

https://www.example.com/wp-json/wp/v2/posts?_fields[]=title&_fields[]=excerpt&per_page=100&offset=100
like image 91
mattmaldre Avatar answered Nov 09 '22 11:11

mattmaldre