Custom Fields
Support MB REST API Custom Post Type by Two Custom Fields via REST API

  • Creator
  • #11583
    Resolved infinitom

    I have a Meta Box added custom post type called 'house' and it contains two custom fields (added via Meta Box) that has the 'street_name' and 'city' for a given house.

    When I query the WP REST API end point for this custom post type, I get all houses and it's not clear from the documentation how I can pass my custom field preference to the end point so that I only get the houses that match the street_name and city I provide it.

    So my question is, how do I retrieve a house via the API by filtering using the two custom fields?

    I've tried to use the WP REST Filter plugin (to restore filter function removed in WP 4.7) and am trying to query the endpoint like this: /house?filter[meta_query][relation]=AND&filter[meta_query][0][key]=street_name&filter[meta_query][0][value]=Evergreen+Terrace&filter[meta_query][1][key]=city&filter&[meta_query][1][value]=Springfield

    Thank you in advance for the help!

Viewing 1 replies (of 1 total)
  • Author
  • #11585
    Anh Tran


    In WordPress 4.7, the filter parameter that filter the query parameters was removed. I found a repository on Github that re-add the filter. It's in the WP-API account on Github, so hopefully, it's official. Please try it.

Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.