Instantly share code, notes, and snippets.

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

Embed
What would you like to do?
Using meta_query With WP API V2
<?php
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' );
<?php
$args = array(
'meta_query' => array(
array(
'key' => 'fruit',
'value' => 'banana',
),
array(
'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