Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
api request with filtering by custom field for Wordpress REST API v1 see:
add_filter( 'json_query_vars', 'slug_allow_meta' );
function slug_allow_meta( $valid_vars ) {
$valid_vars = array_merge( $valid_vars, array( 'meta_key', 'meta_value' ) );
return $valid_vars;
type: 'GET',
url: 'http://xxxxxxxxxx/wp-json/posts?filter[posts_per_page]=20&type[]=page&filter[orderby]=rand&filter[meta_key]=XXXXX&filter[meta_value]=YYYYY',
dataType: 'json'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment