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