set_query_var( string $var, mixed $value )
Set query variable.
Description Description
Parameters Parameters
- $var
-
(string) (Required) Query variable key.
- $value
-
(mixed) (Required) Query variable value.
Source Source
File: wp-includes/query.php
function set_query_var( $var, $value ) {
global $wp_query;
$wp_query->set( $var, $value );
}
Expand full source code Collapse full source code View on Trac
Changelog Changelog
| Version | Description |
|---|---|
| 2.2.0 | Introduced. |
User Contributed Notes User Contributed Notes
You must log in before being able to contribute a note or feedback.
One use case for this is to pass variable to template file when calling it with
get_template_part().// When calling a template with get_template_part() set_query_var('my_form_id', 23); get_template_part('my-form-template');Now in you template you can then call it.
// Inside my-form-template.php $my_form_id = get_query_var('my_form_id');This is a way to pass variables to the called files.
On the a.php file:
On the b.php file:
On the c.php file: