WP_Query::get
Retrieves the value of a query variable.
Method of the class: WP_Query{}
No Hooks.
Returns
Mixed. Contents of the query variable.
Usage
global $wp_query; $wp_query->get( $query_var, $default_value );
- $query_var(string) (required)
- Query variable key.
- $default_value(mixed)
- Value to return if the query variable is not set.
Default:empty string
Changelog
| Since 1.5.0 | Introduced. |
| Since 3.9.0 | The $default_value argument was introduced. |
WP_Query::get() WP Query::get code WP 6.9.1
public function get( $query_var, $default_value = '' ) {
if ( isset( $this->query_vars[ $query_var ] ) ) {
return $this->query_vars[ $query_var ];
}
return $default_value;
}