Coding Stephan

Filter the fields returned by the wordpress api

WordPress is a great platform for running a website with a content management system behind it. Around a year ago the released a plugin called WordPress REST API. And this is a really nice addition to WordPress. This plugin enables you to retrieve all the posts/comments/terms in a really easy JSON format.


In the last few years JSON has become the default way for app developers to fetch remote data in a mobile app. A nice size comparison between XML and JSON can be found here.

So I wanted to use the wordpress rest api for my next project. It is going to be a mobile application. So I wanted to use JSON as it is smaller then XML (less KB = faster app). By default the api sends back a pretty big JSON file, per post. Last post in JSON

We want less data

I though that is not what I want for my new project. Because I only want the necessary data, required for my app. So I created a little plugin that extends the default rest api plugin. It is called REST API – Filter Fields. This plugin allows the developer to filter the returned fields based on a get parameter.

This way I can specify which fields I want returned from the API and reducing the file size of the response. Last post in JSON (only the required fields)

Plugin: REST API – Filter fields

This new plugin is available for free at and the source can be found on Github