BACK TO DIRECTORY

date_query enabler

by arikogan

5.0
(2 ratings)

WP REST API plugin provides the ability to interact with a WordPress installation through a REST API. When retrieving posts, a use case would be to filter them based on they publish date by before/after a certain date. In WordPress this can be achieved using the date_query parameter. However, the parameter is not part of the whitelisted parameters of WP REST API. A workaround is to add it ourselves as discussed here. This plugin adds the date_query param to the whitelist not modifying the theme of WordPress but by using a very small and simple plugin. This allows to change and upgrade themes freely and still keep the whitelisting of the parameter.

After installing WP REST API and this plugin, you should be able to run queries like the below,

/wp-json/wp/v2/posts?filter[date_query][after]=2016-02-26T12:38:36
/wp-json/wp/v2/posts?filter[date_query][before]=2016-02-27T14:28:15

Plugin Details

Active Installs
10
Total Downloads
1,867
Version
0.1
Requires WP
Requires PHP
Tested Up To
4.3.34
Added
2016-03-01
Last Updated
2016-02-28 3:36pm GMT

Ratings

5
2
4
0
3
0
2
0
1
0