WP_Query::get( string $query_var, mixed $default = '' )

Retrieves the value of a query variable.

Parameters

$query_var

(string) (Required) Query variable key.

$default

(mixed) (Optional) Value to return if the query variable is not set.

Default value: ''

Return

(mixed) Contents of the query variable.

Source

File: wp-includes/class-wp-query.php

public function get( $query_var, $default = '' ) {
		if ( isset( $this->query_vars[ $query_var ] ) ) {
			return $this->query_vars[ $query_var ];
		}

		return $default;
	}

Changelog

Version Description
3.9.0 The $default argument was introduced.
1.5.0 Introduced.

© 2003–2021 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/classes/wp_query/get