WordPress filter hook
rest_query_vars
Fired by 6 WordPress plugins, running on 40K+ sites between them.
“Filter allowed query vars for the REST API.”
How to use rest_query_vars
It's a filter: your callback receives the value, and must return the (changed) value.
Add this to your theme's functions.php or a small custom plugin:
add_filter( 'rest_query_vars', function( $valid_vars ) {
// Change $valid_vars here.
return $valid_vars;
}, 10, 1 );Argument names come from Seriously Simple Podcasting's source. Other plugins may pass different values: check the call in the plugin you're targeting below.
6 plugins that fire rest_query_vars
Sorted by active installs. Each entry shows where the plugin calls the hook and what it passes.
-
Seriously Simple Podcasting20,000+ installs
apply_filters( 'rest_query_vars', $valid_vars )php/classes/rest/class-episodes-rest-controller.php:1045 -
GamiPress10,000+ installs
apply_filters( 'rest_query_vars', $valid_vars )includes/api/class-wp-rest-gamipress-posts-controller.php:326 -
WordPress REST API (Version 2)10,000+ installs
apply_filters( 'rest_query_vars', $valid_vars )lib/endpoints/class-wp-rest-posts-controller.php:757 -
Appmaker WP100+ installs
apply_filters( 'rest_query_vars', $valid_vars )lib/endpoints/appmaker/class-appmaker-wp-rest-backend-posts-controller.php:425 -
WP Rest Api V2 Multiple PostTypes100+ installs
apply_filters( 'rest_query_vars', $valid_vars )lib/endpoints/class-wp-rest-multiple-posttype-controller.php:339 -
Booking WeirFewer than 10 installs
apply_filters( 'rest_query_vars', $GLOBALS['wp']->public_query_vars )includes/core/events/EventPostType.php:832
Need a customisation built on this hook?
Tell us what you want to change and which plugin it's for. We'll write it, test it and send it back as a small plugin.