How to filter or search the posts using postmeta tables custom meta fields with wordpress REST API

You will need to add custom query vars:

add_filter('rest_query_vars', 'wpse225850_add_rest_query_vars');

function wpse225850_add_rest_query_vars($query_vars) {

    $query_vars = array_merge( $query_vars, array('meta_key', 'meta_value', 'meta_compare') );

    return $query_vars;

}

Now, get your posts at example.com/wp-json/wp/v2/posts?filter[meta_key]=property_featured&filter[meta_value]=1.

You can follow this ticket for more info.

Leave a Comment