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