WordPress at a glance

get_query_var() WP 1.0

Retrieve variable in the WP_Query class.

  • Global. WP_Query. $wp_query Global WP_Query instance.
  • Since 3.9.0 The $default argument was introduced.
Works based on: WP_Query::get()
✈ 1 time = 0.000021s = very fast | 50000 times = 0.06s = speed of light

No Hooks.


Mixed. Contents of the query variable.


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

Code of get query var: wp-includes/query.php WP 5.2.1

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

Related Functions

From tag: query

More from category: Main Query

No comments
    Hello, !     Log In . Register