本地安装上的空WP_QUERY对象

时间:2011-03-22 作者:kaiser

我才意识到*empty WP_Query object* 在我的普通wordpress上安装。我重置了DB,停用了所有插件,并激活了TwentyTen作为主题,但每个请求(面向公共和管理)的完整对象都是空的。无论我是请求“Hello World”帖子还是404. 一切都是空的。这有什么原因?

Edit 1<这是我检查的方式WP_Query:

// inserted on top of the functions.php file, 
// so it\'s equal to a function hooked into the \'after_setup_theme\' hook  
// i also tried other hooks (which should make no difference) and got the same result.
    echo \'<pre>\'; 
        print_r($GLOBALS[\'wp_query\']); 
    echo \'</pre>\';
这是print_r();

WP_Query Object
(
    [query] => 
    [query_vars] => Array
        (
        )

    [tax_query] => 
    [queried_object] => 
    [queried_object_id] => 
    [request] => 
    [posts] => 
    [post_count] => 0
    [current_post] => -1
    [in_the_loop] => 
    [post] => 
    [comments] => 
    [comment_count] => 0
    [current_comment] => -1
    [comment] => 
    [found_posts] => 0
    [max_num_pages] => 0
    [max_num_comment_pages] => 0
    [is_single] => 
    [is_preview] => 
    [is_page] => 
    [is_archive] => 
    [is_date] => 
    [is_year] => 
    [is_month] => 
    [is_day] => 
    [is_time] => 
    [is_author] => 
    [is_category] => 
    [is_tag] => 
    [is_tax] => 
    [is_search] => 
    [is_feed] => 
    [is_comment_feed] => 
    [is_trackback] => 
    [is_home] => 
    [is_404] => 
    [is_comments_popup] => 
    [is_paged] => 
    [is_admin] => 
    [is_attachment] => 
    [is_singular] => 
    [is_robots] => 
    [is_posts_page] => 
    [is_post_type_archive] => 
    [parsed_tax_query] => 
)

1 个回复
最合适的回答,由SO网友:scribu 整理而成

它是空的,因为您在它有机会被填充之前就看到了它。

功能的顶部。php还为时过早。您应该在“template\\u redirect”操作中执行此操作。

或者,更好的方法是使用调试栏插件。

结束

相关推荐