在wordpress中获得热门帖子

在wordpress中获得热门帖子,wordpress,wordpress-theming,custom-wordpress-pages,Wordpress,Wordpress Theming,Custom Wordpress Pages,我想在wordpress的侧边栏中获得最后5篇热门帖子。 但是不要工作。为什么? $popularpost = new WP_Query( array( 'meta_key' => 'post_views_count', 'orderby' => 'meta_value_num', 'posts_per_page' => 5 ) ); if ($popularpost-&

我想在wordpress的侧边栏中获得最后5篇热门帖子。 但是不要工作。为什么?

$popularpost = new WP_Query( array(
            'meta_key' => 'post_views_count',
            'orderby' => 'meta_value_num',
            'posts_per_page' => 5
        ) );


        if ($popularpost->have_posts()) {
            while ( $popularpost->have_posts() ) : $popularpost->the_post() ?>

            <article class="post-side">
                <span><?php the_date(); ?></span>
                <a href="<?php the_permalink(); ?>" target="_parent"><h5><?php the_title(); ?></h5></a>
            </article>

        <?php endwhile; } ?>
$popularpost=新的WP\U查询(数组)(
“meta_key”=>“post_views_count”,
'orderby'=>'meta_value_num',
“每页帖子数”=>5
) );
如果($popularpost->have_posts()){
而($popularpost->have_posts()):$popularpost->the_post()?>