Last active
February 6, 2021 16:53
-
-
Save Igcorreia/63dd0add4a7799541500afa69141eb80 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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