apply_filters( 'query_vars', string[] $public_query_vars )

Filters the query variables whitelist before processing.


Description 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 Parameters

$public_query_vars

(string[]) The array of whitelisted query variable names.


Top ↑

Source Source

File: wp-includes/class-wp.php

View on Trac


Top ↑

Changelog Changelog

Changelog
Version Description
1.5.0 Introduced.

Top ↑

More Information More Information

This filter allows query vars to be added, removed, or changed prior to executing the query.

Top ↑

Example Example


function themeslug_query_vars( $qvars ) {
	$qvars[] = 'custom_query_var';
	return $qvars;
}
add_filter( 'query_vars', 'themeslug_query_vars' );



Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.