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

Retrieve query variable.

Parameters Parameters


(string) (Required) Query variable key.


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

Default value: ''

Top ↑

Return Return

(mixed) Contents of the query variable.

Top ↑

Source 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;

Top ↑

Changelog Changelog

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

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.