先从插件管理那边找到WP-PostViews,进行安装。安装完成之后在widgets那边就有了一个WP-PostViews的一个浏览排行组件。如果想要让每篇文章显示浏览次数,就修改模板首页(index.php)和内容页(single.php),在appearance那里的editor里面找到Main Index Template (index.php),我想把浏览次数放在评论数之后,于是找到<?php comments_popup_link(__(‘No Comments’), __(‘1 Comment’), __(‘% Comments’)); ?>,在后面插入<?php if(function_exists(‘the_views’)) { the_views(); } ?>,文件的内容由于模板的不同会有所不一样,这个要自己去了解一下。在Single Post(single.php)中也同样找到合适的位置插入<?php if(function_exists('the_views')) { the_views(); } ?>。还可以显示页面的浏览次数,只要同样修改
Page Template (page.php)就可以了。
用WP-PostViews插件显示wordpress每篇文章的浏览次数
Comments
One response to “用WP-PostViews插件显示wordpress每篇文章的浏览次数”
-
啥时候,我也试试。
Leave a Reply
You must be logged in to post a comment.