Wordpress:在循环中检索帖子视图?

时间:2014-01-12 05:20:08

标签: php wordpress content-management-system

我有一个循环显示博客帖子标题,摘录和阅读更多链接。

我还希望包含每篇博文在循环中的观看量。

我尝试过使用各种视图计数插件,但似乎没有一个在循环中工作。

有人知道是否有办法直接从数据库中检索此信息,将视图与帖子ID配对?

我的循环是:

 <div id="bloglist">
        <?php query_posts('category_name=blog&showposts=6'); while (have_posts()) : the_post(); ?>
                        <div class="panel">
                            <div class="panel-wrapper">

                             <div class="blogstats">
                               <div>ID: <?php  $postid = the_ID(); echo $postid; ?></div>
                               <div>Views: <?php echo_post_views($postid); ?> </div>
                             </div><!--BLOGSTATS--->
                                <div class="excerpt"><?php the_excerpt(); ?></div>
                                <a class="readmore" href="<?php the_permalink(); ?>">Read More</a>
                            </div>
                            </div>
                    <?php endwhile; wp_reset_query(); ?>

 </div><!--BLOGLIST-->

我目前无法使用WP-post-view插件

1 个答案:

答案 0 :(得分:0)

我建议使用这个插件 WP-PostViews

我为改变插件设置添加了图片

image WP-PostViews setting

祝你好运。