在獲取查詢變量:get query var這篇文章中提到了WordPress查詢變量,WordPress有兩種類型的保留變量:public_query_vars 和 private_query_vars
$public_query_vars = array('m', 'p', 'posts', 'w', 'cat', 'withcomments', 'withoutcomments', 's', 'search', 'exact', 'sentence', 'debug', 'calendar', 'page', 'paged', 'more', 'tb', 'pb', 'author', 'order', 'orderby', 'year', 'monthnum', 'day', 'hour', 'minute', 'second', 'name', 'category_name', 'tag', 'feed', 'author_name', 'static', 'pagename', 'page_id', 'error', 'comments_popup', 'attachment', 'attachment_id', 'subpost', 'subpost_id', 'preview', 'robots', 'taxonomy', 'term', 'cpage', 'post_type');
$private_query_vars = array('offset', 'posts_per_page', 'posts_per_archive_page', 'showposts', 'nopaging', 'post_type', 'post_status', 'category__in', 'category__not_in', 'category__and', 'tag__in', 'tag__not_in', 'tag__and', 'tag_slug__in', 'tag_slug__and', 'tag_id', 'post_mime_type', 'perm', 'comments_per_page');
對(duì)于公開查詢變量public_query_vars,我們可以直接使用get_query_var函數(shù)獲取查詢變量的值,而私有查詢變量private_query_vars是WordPress后臺(tái)使用的,通過get_query_var是獲取不到這些變量的值的。
在創(chuàng)建自定義查詢變量或者添加URL重定向規(guī)則的時(shí)候,我們不能再使用以上任一個(gè)變量名了,否則就會(huì)出現(xiàn)404或者一些奇怪的錯(cuò)誤。


