致命错误:在null上调用成员函数have_posts()

时间:2017-01-27 17:53:53

标签: php wordpress

你能否告诉我在那里做错了什么:

$popular_posts_args = new wp_query( array(
                                'post_type'         => 'blog',
                                'post_status'       => 'publish',
                                'orderby'           => 'meta_value_num',
                                //'meta_value'        => '1',
                                'order'             => 'DESC',
                                'meta_key'          => 'my_post_viewed',
                                'posts_per_page'    => $number
                                )
                            );
query_posts( $popular_posts_loop ); 
 while( $popular_posts_loop->have_posts() ): 
      $popular_posts_loop->the_post();
wp_reset_query();

这一行:

query_posts( $popular_posts_loop ); 
 while( $popular_posts_loop->have_posts() ): 
        $popular_posts_loop->the_post();

1 个答案:

答案 0 :(得分:0)

哎呀,对不起伙计我刚刚意识到我有

$ popular_posts_loop

而不是$ popular_posts_args

现在很好!