Skip to content
This repository has been archived by the owner on Aug 14, 2019. It is now read-only.

WP-API/rest-filter-response-fields

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NOTE: This plugin was created to test a feature which has since landed in WordPress core. To request specific fields with your REST API response, you may use the _fields query parameter introduced in WordPress 4.9.

Usage:

Example Query Result
/wp/v2/posts?_fields=id,title Return a posts collection where each post includes only the id property and title object.
/wp/v2/media?_fields=source_url Return a media collection where each object includes only the source_url.
/wp/v2/tags?_fields[]=slug&_fields[]=id Return tag objects with only the id and slug properties.

As noted in the above examples, the core implementation supports using query parameter array syntax or a comma-separated list.

Legacy plugin README below, for posterity.


REST Filter Response Fields

Specify fields for the response JSON. See https://core.trac.wordpress.org/ticket/38131.

Use by specifying the fields you want as part of the request as a comma delimited list: ?fields=title,excerpt.

About

Legacy plugin; use ?_fields= instead of installing this!

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published