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? Commented Apr 25, 2017 at 13:14
  • WP version 4.7.4 Commented Apr 25, 2017 at 13:25

1 Answer 1

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). Commented Apr 25, 2017 at 13:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.