WP_Query::fill_query_vars() WordPress Method
The WP_Query::fill_query_vars() function fills in the query variables, which are used by the Wordpress query class. The function sets the values for the following variables: $_GET $_POST $_COOKIE $_SERVER $_REQUEST These variables are used by the query class to construct the SQL query. The fill_query_vars() function is called by the query class when it is initialized.
WP_Query::fill_query_vars( array $query_vars ) #
Fills in the query variables, which do not exist within the parameter.
Parameters
- $query_vars
(array)(Required)Defined query variables.
Return
(array) Complete query variables with undefined ones filled in empty.
Source
File: wp-includes/class-wp-query.php
public function fill_query_vars( $query_vars ) {
$keys = array(
'error',
'm',
'p',
'post_parent',
'subpost',
'subpost_id',
'attachment',
'attachment_id',
'name',
'pagename',
'page_id',
'second',
'minute',
'hour',
'day',
'monthnum',
'year',
'w',
'category_name',
'tag',
'cat',
'tag_id',
'author',
'author_name',
'feed',
'tb',
'paged',
'meta_key',
'meta_value',
'preview',
's',
'sentence',
'title',
'fields',
'menu_order',
'embed',
);
foreach ( $keys as $key ) {
if ( ! isset( $query_vars[ $key ] ) ) {
$query_vars[ $key ] = '';
}
}
$array_keys = array(
'category__in',
'category__not_in',
'category__and',
'post__in',
'post__not_in',
'post_name__in',
'tag__in',
'tag__not_in',
'tag__and',
'tag_slug__in',
'tag_slug__and',
'post_parent__in',
'post_parent__not_in',
'author__in',
'author__not_in',
);
foreach ( $array_keys as $key ) {
if ( ! isset( $query_vars[ $key ] ) ) {
$query_vars[ $key ] = array();
}
}
return $query_vars;
}
Expand full source codeCollapse full source codeView on TracView on GitHub
Changelog
| Version | Description |
|---|---|
| 4.5.0 | Removed the comments_popup public query variable. |
| 2.1.0 | Introduced. |