set_query_var() WordPress Function

The set_query_var() function allows you to set a custom query variable for the current query. This function can be useful for customizing the behavior of plugins and themes.

set_query_var( string $var, mixed $value ) #

Sets the value of a query variable in the WP_Query class.


Parameters

$var

(string)(Required)Query variable key.

$value

(mixed)(Required)Query variable value.


Top ↑

Source

File: wp-includes/query.php

function set_query_var( $var, $value ) {
	global $wp_query;
	$wp_query->set( $var, $value );
}


Top ↑

Changelog

Changelog
VersionDescription
2.2.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.