query_vars WordPress Filter Hook
The query_vars hook allows you to add custom query variables to the WordPress URL. This can be useful for passing information to your scripts or plugins.
apply_filters( 'query_vars', string[] $public_query_vars ) #
Filters the query variables allowed before processing.
Description
Allows (publicly allowed) query vars to be added, removed, or changed prior to executing the query. Needed to allow custom rewrite rules using your own arguments to work, or any other custom query variables you want to be publicly available.
Parameters
- $public_query_vars
(string[])The array of allowed query variable names.
More Information
This filter allows query vars to be added, removed, or changed prior to executing the query.
Example
function myplugin_query_vars( $qvars ) { $qvars[] = 'custom_query_var'; return $qvars; } add_filter( 'query_vars', 'myplugin_query_vars' );
Source
File: wp-includes/class-wp.php
Changelog
Version | Description |
---|---|
1.5.0 | Introduced. |