3

I'm using Wordpress API just to perform some tests. I'm currently working with the date_query parameter, which, in my case, doesn't work as expected.

Just consider this request : https://wptest.enguerranweiss.com/wp-json/wp/v2/posts?filter[orderBy]=date&filter[order]=DESC&filter[date_query][after]=2016-10-13T17 (dummy install, dummy content)

What I expect : the API should only return the posts more recent than 2016-10-13. Right now, the filter seems to be ignored.

Any idea?

2
  • Which version of WordPress are you using? – Laxmana Apr 25 '17 at 13:14
  • WP version 4.7.4 – enguerranws Apr 25 '17 at 13:25
3

As of WP >= 4.7 filter[] is not supported and have been removed. Also WP REST API Plugin became part of WordPress Core.

According docs your link should be:

https://wptest.enguerranweiss.com/wp-json/wp/v2/posts?orderby=date&order=desc&after=2016-10-13T17:00:00

EDIT

As enguerranws mentioned the date should be in ISO8601 format

1
  • 2
    Damned, I've searched for this doc for hours. Thanks, just to complete your answer : the after param should be an ISO8601 date string (or WP returns an error). – enguerranws Apr 25 '17 at 13:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.