Skip to content

Instantly share code, notes, and snippets.

@yoren yoren/functions.php
Last active Feb 29, 2016

What would you like to do?
Using meta_query With WP API V2
function my_allow_meta_query( $valid_vars ) {
$valid_vars = array_merge( $valid_vars, array( 'meta_key', 'meta_value', 'meta_query' ) ); // Omit meta_key, meta_value if you don't need them
return $valid_vars;
add_filter( 'rest_query_vars', 'my_allow_meta_query' );
$args = array(
'meta_query' => array(
'key' => 'fruit',
'value' => 'banana',
'key' => 'animal',
'value' => 'lion',
$query = new WP_Query( $args );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.