WP_Query::get()publicWP 1.5.0

Retrieves the value of a query variable.

Method of the class: WP_Query{}

No Hooks.


Mixed. Contents of the query variable.


global $wp_query;
$wp_query->get( $query_var, $default_value );
$query_var(string) (required)
Query variable key.
Value to return if the query variable is not set.
Default: empty string


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

WP_Query::get() code WP 6.3

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

	return $default_value;