Skip to content

Instantly share code, notes, and snippets.

@Igcorreia
Last active February 6, 2021 16:53
Show Gist options
  • Save Igcorreia/63dd0add4a7799541500afa69141eb80 to your computer and use it in GitHub Desktop.
Save Igcorreia/63dd0add4a7799541500afa69141eb80 to your computer and use it in GitHub Desktop.
// EDIT YOUR POST TYPE
// Add it to functions.php one per post type
add_filter( 'rest_YOURPOSTTYPE_query', function( $args ) {
$args['meta_query'][] = array();
$ignore = array('status','per_page', 'page', 'search','order','orderby', 'slug', 'exclude', 'lang', 'offset', 'chapter','guid','type');
foreach ( $_GET as $key => $value ) {
if (!in_array($key, $ignore)) {
$args['meta_query'][] = array(
'key' => $key,
'value' => esc_sql($value),
);
}
}
return $args;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment