2
votes

I am using the plugin wordpress' RESTful API plugin called JSON API and I would like to get posts from a given date. I tried many parameters but it didn't work for me, can you help me please?

Here is what I have tested for instance :

http://www.example.com/?json=get_date_posts&date=20140806&posts_per_page=-1

or

http://www.example.com/?json=get_posts&after=20140806&posts_per_page=-1

3
What didn't work? maybe posts_per_page -1 ? Or date like 2014-15-08 - Daniel W.
The API is returning all posts from the creation of my website to 20140806 (using 2014-08-06 didn't change anything). In fact it is like the parameter after behave exactly like before - Moussa

3 Answers

1
votes

This WP plugin has documentation JSON API Docs.

Please see this part Method:get_posts this call accepts the same parameters as WordPress's WP_Query parameters, which can be found here WP_Query parameters.

The part you are looking for is Date parameters.

Example: http://www.example.com/?json=get_date_posts&year=2012&monthnum=12&day=12&posts_per_page=-1

0
votes

don't if it still helps but you should use something like this: json=get_date_posts&date=after%2020150318

0
votes

You can get all posts from a date using get_posts with params below

count = -1

date_query[0][after] = 20160101

http://www.example.com/api/get_posts/?count=-1&date_query%5B0%5D%5Bafter%5D=20160101

You can see all date params on https://codex.wordpress.org/Class_Reference/WP_Query#Date_Parameters