2
从docs $查询和$ query_vars之间的区别:什么是在全球WP_Query
$query
Holds the query string that was passed to the $wp_query object by WP class.
$query_vars
An associative array containing the dissected $query: an array of the query variables and their respective values.
但是,当我做这样的事情:
$args = array(
'post_type' => 'post',
'posts_per_page' => 10,
'post_status' => 'publish'
);
$author_query = new WP_Query($args);
那么所有这些论点去$query_vars
我可以从print_r($wp_query)
中看到,那么$query
的目的是什么,以及如何调整此属性的值。
我很好奇,因为当我去作者模板query
属性在这个页面中包含像[author_name] => admin
?
中的工作原理。它实际上是相反的。 '$ query'包含原始_raw_参数,'$ query_vars'包含_parsed_参数。 前者仅包含您传递的参数以及由URI提取的参数,后者包含所有未定义的变量填充为空的变量。 – Chauncey 2018-01-25 15:10:23