Forum Replies Created

Viewing 1 replies (of 1 total)
  • We seem to be experiencing a similar issue (the same issue?) that appeared immediately after the upgrade to WordPress 4.7.

    We have custom post types and use a filter on rest_query_vars to allow an authenticated user to query on meta_query.

    add_filter( 'rest_query_vars', array( $this, 'allow_meta_query' ) );
    ...
            public function allow_meta_query( $valid_vars ) {
                    $valid_vars = array_merge( $valid_vars, array(
                            'meta_key', 'meta_value', 'meta_compare', 'meta_query'
                    ) );
    
                    return $valid_vars;
            }
    

    So, a query such as:

    /wp-json/wp/v2/our-custom-post-type?filter[meta_query][0][key]=a_meta_field&[meta_query][0][value]=something&[meta_query][0][relation]=AND

    would return items that have the meta field a_meta_field with the value something.

    After the upgrade to WordPress 4.7, such a query as above now returns all of the custom post type, rather than just items that match that meta query.

Viewing 1 replies (of 1 total)