我有http://localhost/testsite1/coder2/?id=71
带参数的 url id=71
。
当我在 WordPress 中开发时,我无法使用$_GET['id']
,因此需要使用get_query_var('id')
来访问参数。
然而,这并没有产生任何结果。
当我通过运行代码查看所有变量时:
global $wp_query;
var_dump($wp_query->query_vars);
...我在任何地方都看不到id
参数。
C:\wamp64\www\testsite1\wp-content\plugins\CSUKCODER\csukcoder.php:92:
array (size=64)
'page' => int 0
'pagename' => string 'coder2' (length=6)
'error' => string '' (length=0)
'm' => string '' (length=0)
'p' => int 0
'post_parent' => string '' (length=0)
'subpost' => string '' (length=0)
'subpost_id' => string '' (length=0)
'attachment' => string '' (length=0)
'attachment_id' => int 0
'name' => string 'coder2' (length=6)
'page_id' => int 0
'second' => string '' (length=0)
'minute' => string '' (length=0)
'hour' => string '' (length=0)
'day' => int 0
'monthnum' => int 0
'year' => int 0
'w' => int 0
'category_name' => string '' (length=0)
'tag' => string '' (length=0)
'cat' => string '' (length=0)
'tag_id' => string '' (length=0)
'author' => string '' (length=0)
'author_name' => string '' (length=0)
'feed' => string '' (length=0)
'tb' => string '' (length=0)
'paged' => int 0
'meta_key' => string '' (length=0)
'meta_value' => string '' (length=0)
'preview' => string '' (length=0)
's' => string '' (length=0)
'sentence' => string '' (length=0)
'title' => string '' (length=0)
'fields' => string '' (length=0)
'menu_order' => string '' (length=0)
'embed' => string '' (length=0)
'category__in' =>
array (size=0)
empty
'category__not_in' =>
array (size=0)
empty
'category__and' =>
array (size=0)
empty
'post__in' =>
array (size=0)
empty
'post__not_in' =>
array (size=0)
empty
'post_name__in' =>
array (size=0)
empty
'tag__in' =>
array (size=0)
empty
'tag__not_in' =>
array (size=0)
empty
'tag__and' =>
array (size=0)
empty
'tag_slug__in' =>
array (size=0)
empty
'tag_slug__and' =>
array (size=0)
empty
'post_parent__in' =>
array (size=0)
empty
'post_parent__not_in' =>
array (size=0)
empty
'author__in' =>
array (size=0)
empty
'author__not_in' =>
array (size=0)
empty
'ignore_sticky_posts' => boolean false
'suppress_filters' => boolean false
'cache_results' => boolean true
'update_post_term_cache' => boolean true
'lazy_load_term_meta' => boolean true
'update_post_meta_cache' => boolean true
'post_type' => string '' (length=0)
'posts_per_page' => int 10
'nopaging' => boolean false
'comments_per_page' => string '50' (length=2)
'no_found_rows' => boolean false
'order' => string 'DESC' (length=4)
我究竟做错了什么?