• This technique doesn’t seem to work anymore now that the API is in core. On my production server 4.6.1 the below correctly comes back with no results, but on 4.7 I get a full result set as if that filter wasn’t there.

    ?filter[date_query][after]=2016-12-20T17:51:38

    Anybody else seeing this?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter chrishaff

    (@chrishaff)

    OK, so evidently the filter went away when it moved into core. There is this plugin that should restore it, alas I’ve got no luck with that one.

    https://github.com/WP-API/rest-filter/blob/master/plugin.php

    Yep, I’m seeing the same thing. That plugin you reference lets me do filter[tag] again, which also was taken away by WP 4.7, but it didn’t add date_query for filters.

    It’s unfortunate that WP 4.7 allows us to remove the REST API plugin, but requires at least one or two more plugins to get it back to the state it was in before.

    Thread Starter chrishaff

    (@chrishaff)

    @doofusdavid, I haven’t been able to get 4.7 back to the previous state. As I mentioned, I went back to 4.6.1 hoping that this feature comes back (via core or plugins). My attempts at plugins have not worked (and I stopped no that track for now).

    Thanks for any hints.

    So, I’ve found a workaround that does work for me. I borrowed some code I found on that plugin site, and tailored it for date_query.

    Add the following to your functions.php:

    function add_query_vars_filter( $vars ){
    $vars = array_merge( $vars, array( 'date_query') );
    return $vars;
    }
    add_filter( 'query_vars', 'add_query_vars_filter' );
    
    

    @doofusdavid i have added your snippet on function.php but it doesn’t work for my query:

    /wp-json/wp/v2/posts?filter[date_query][column]=post_modified_gmt&filter[date_query][after]=2017-03-20T15:04:39

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Doesn’t appear to work with 4.7’ is closed to new replies.