On this page
WP_Query::get( string $query_var, mixed $default_value = '' ): mixed
Retrieves the value of a query variable.
Parameters
$query_varstring Required-
Query variable key.
$default_valuemixed Optional-
Value to return if the query variable is not set.
Default:
''
Return
mixed Contents of the query variable.
Source
File: wp-includes/class-wp-query.php. View all references
public function get( $query_var, $default_value = '' ) {
if ( isset( $this->query_vars[ $query_var ] ) ) {
return $this->query_vars[ $query_var ];
}
return $default_value;
}
Related
Used By
| Used By | Description |
|---|---|
| WP_Query::generate_postdata() wp-includes/class-wp-query.php | Generate post data. |
| WP_Query::is_feed() wp-includes/class-wp-query.php | Is the query for a feed? |
| WP_Query::get_queried_object() wp-includes/class-wp-query.php | Retrieves the currently queried object. |
| WP_Query::is_post_type_archive() wp-includes/class-wp-query.php | Is the query for an existing post type archive page? |
| get_query_var() wp-includes/query.php | Retrieves the value of a query variable in the WP_Query class. |
| get_body_class() wp-includes/post-template.php | Retrieves an array of the class names for the body element. |
Changelog
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/classes/wp_query/get