WordPress at a glance

get_query_var() WP 1.0

Retrieve variable in the WP_Query class.

Works based on: WP_Query::get()
1 time — 0.000021 sec (very fast) | 50000 times — 0.06 sec (speed of light)

No Hooks.

Return

Mixed. Contents of the query variable.

Usage

get_query_var( $var, $default );
$var(string) (required)
The variable key to retrieve.
$default(mixed)
Value to return if the query variable is not set.
Default: ''

Notes

  • Global. WP_Query. $wp_query WordPress Query object.

Changelog

Since 1.5.0 Introduced.
Since 3.9.0 The $default argument was introduced.

Code of get_query_var() WP 5.7.1

<?php
function get_query_var( $var, $default = '' ) {
	global $wp_query;
	return $wp_query->get( $var, $default );
}

From tag: query

More from category: Main Query

vladlu 100vlad.lu
Editors: Kama 100
No comments
    Log In