• Bluejay256

    (@bluejay256)


    According to the docs, filter was removed and superseded by the use of fields such as

    wp-json/wp/v2/entity/category=1

    But that doesn’t seem to work with meta fields. I also attempted to use the plugin referenced to restore ‘filter’ but that doesn’t seem to work with meta fields either.

    Several hours of Googling seems to have resulted in nothing but out of date approach that don’t work as of 4.7. Is this simply no longer possible? Does anyone have a link to a working resource as to how to query by meta in 4.7+?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator bcworkz

    (@bcworkz)

    Apparently meta fields are not supported by default, but I did see the filter “rest_post_query” where you can add WP_Query arguments to use such as ‘meta_key’ and ‘meta_value’.

    I can’t tell you much more about using this, as I’m not up to speed with the REST API. I do know enough PHP to know when something looks useful though. Naturally you would need to be able to add custom PHP code to the target site. You should examine the passed parameters to be sure, but it appears you add the query args as array keys and the associated values from the request are assigned to each added element.

    If you go down to line 284 from the above link, you can see the prepared query args are used directly in WP_Query::query(). I hope this helps you work something out. Good luck!

    Thread Starter Bluejay256

    (@bluejay256)

    Thanks. I will give it a shot and post my results.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘REST Queries with Meta Fields’ is closed to new replies.