Filter by custom field (meta_key) using JSON API

Hi I’m using the great JSON API for WordPress and would like to filter my custom post types by a specific custom field (using the meta_key and meta_value params).

The query in my URL looks like this so far:

Read More

http://example.org?json=get_recent_posts&post_type=mytype&custom_fields=myfield&include=title,custom_fields&meta_key=myfield&meta_value=myvalue

However, it still returns all the posts (from that post type), no matter whether or not they contain the custom field mapping.

What’s wrong?
Thanks in advance for any help.

Related posts

Leave a Reply

1 comment

  1. As this is too much for a comment, I’ll post here and delete later:

    http://example.org // domain
    ?json=get_recent_posts // controller
    # Arguments for the query start here
    &post_type=mytype 
    &custom_fields=myfield
    &include=title,custom_fields
    &meta_key=myfield
    &meta_value=myvalue
    

    Have you tried the following?

    • Debug the response: http://www.example.org/api/get_page_index/?dev=1
    • Widget-style JSONP output: http://www.example.org/api/get_recent_posts/?callback=show_posts_widget&read_more=More&count=3
    • Redirect on error: http://www.example.org/api/posts/create_post/?callback_error=http%3A%2F%2Fwww.example.org%2Fhelp.html

    And could you post what you get out from the debug?