WP JSON API meta_query not working

Per the comment from @ialocin I switched from WP JSON API to WP REST API. There is much less documentation with the rest api but it’s customizable using native wordpress functions. Also, it has a nifty github plugin for allowing use with ACF custom fiends.

Anyway, the documentatino for customization the wp rest api is terrible so I’m going to show you what I did as of wp 4.2.0 + wp rest api 1.2.1

First thing is to add an action to the plugin so that it will pick up your new rest actions. Do that in wp-content/plugins/[rest-api-folder]/plugins.php. I personally added all this at the bottom of the file.

require_once( dirname( __FILE__ ) . '/lib/class-myplugin-api-mytype.php' );

function myplugin_api_init() {
    global $myplugin_api_mytype;

    $myplugin_api_mytype = new MyPlugin_API_MyType();
    add_filter( 'json_endpoints', array( $myplugin_api_mytype, 'register_routes' ) );
}
add_action( 'wp_json_server_before_serve', 'myplugin_api_init' );

Now it’s time to add your new class which is where the meat is. Create the file wp-content/plugins/[rest-api-folder]/lib/class-myplugin-api-mytype.php and put this into it:

<?php

class MyPlugin_API_MyType {
    public function register_routes( $routes ) {
        $routes['/test'] = array(
            array( array( $this, 'test'), WP_JSON_Server::READABLE ),
        );
        // $routes['/myplugin/mytypeitems'] = array(
            // array( array( $this, 'get_posts'), WP_JSON_Server::READABLE ),
            // array( array( $this, 'new_post'), WP_JSON_Server::CREATABLE | WP_JSON_Server::ACCEPT_JSON ),
        // );
        // $routes['/myplugin/mytypeitems/(?P<id>\d+)'] = array(
        //  array( array( $this, 'get_post'), WP_JSON_Server::READABLE ),
        //  array( array( $this, 'edit_post'), WP_JSON_Server::EDITABLE | WP_JSON_Server::ACCEPT_JSON ),
        //  array( array( $this, 'delete_post'), WP_JSON_Server::DELETABLE ),
        // );

        // Add more custom routes here

        return $routes;
    }

    public function test( $filter = array(), $context="view", $type="post", $page = 1 ) {
        return array("status" => "ok", "message" => "it worked!");
    }
}

?>

Now go to your worpress page with “/wp-json/test” at the end of the url (no querystring) and you should see

{"status":"ok","message":"it worked!"}

Viola! Also you can look at /libs/class-wp-json-posts.php and copy mechanisms in there as needed. I hope this saves someone all the time it took me to figure this out!