inove主题通过wp-postviews插件的方法设置在主页及文章页设置浏览次数

inove主题通过wp-postviews插件的方法设置在主页及文章页设置浏览次数需要

一、安装wp-postviews

登入网站后台—插件—安装插件—搜索wp-postviews即可

二、在首页显示的每篇文章的浏览次数

需要编辑的文件为主题目录下的index.php文件,所在的目录为/domains/liangzhaojun.com/public_html/wp-content/themes/inove/(此目录为用ftp连接到网站所在主机上的目录)。

打开index.php文件找到如下代码:

<?php if ($options[‘author’]) : ?><span class=”author”><?php the_author_posts_link(); ?></span><?php endif; ?>
<?php edit_post_link(__(‘Edit’, ‘inove’), ‘<span class=”editpost”>’, ‘</span>’); ?>
<span class=”comments”><?php comments_popup_link(__(‘No comments’, ‘inove’), __(‘1 comment’, ‘inove’), __(‘% comments’, ‘inove’), ”, __(‘Comments off’, ‘inove’)); ?></span>

在上面代码下面添加如下代码:

<span class=”comments”> <a href ><?php if(function_exists(‘the_views’)) { the_views(); } ?></a></span>

注意:其实下面需要修改文件添加的代码是相同的代码。

三、在具体的每篇文章中显示浏览次数

需要编辑的文件为主题下的single.php文件,所在的目录与index.php在相同的目录。

打开single.php文件找到如下代码:

<?php edit_post_link(__(‘Edit’, ‘inove’), ‘<span class=”editpost”>’, ‘</span>’); ?>
<?php if ($comments || comments_open()) : ?>
<span class=”addcomment”><a href=”#respond”><?php _e(‘Leave a comment’, ‘inove’); ?></a></span>
<span class=”comments”><a href=”#comments”><?php _e(‘Go to comments’, ‘inove’); ?></a></span>

在上面代码的下面添加如下代码:

<span class=”comments”> <a href ><?php if(function_exists(‘the_views’)) { the_views(); } ?></a></span>

四、在插件中设置显示的文字

进入网站后台—设置—PostViews找到Allowed Variables:- %VIEW_COUNT% 在后面的框中编辑要显示的文字即可,其中%VIEW_COUNT%味阅读次数的参数不要删掉。

附:如果需要在归档的文章中也显示浏览次数(我的博客是下拉列表的形式显示归档的所以没有体现出来浏览次数),需要修改主题目录下的archive.php 文件,与index.php、single.php在相同的目录。

打开archive.php文件找到如下代码:

<?php if ($options[‘author’]) : ?><span class=”author”><?php the_author_posts_link(); ?></span><?php endif; ?>
<?php edit_post_link(__(‘Edit’, ‘inove’), ‘<span class=”editpost”>’, ‘</span>’); ?>
<span class=”comments”><?php comments_popup_link(__(‘No comments’, ‘inove’), __(‘1 comment’, ‘inove’), __(‘% comments’, ‘inove’), ”, __(‘Comments off’, ‘inove’)); ?></span>

在上面代码的下面添加如下代码:

<span class=”comments”> <a href ><?php if(function_exists(‘the_views’)) { the_views(); } ?></a></span>

参考:

1、Edward’Blog                 http://www.edward-han.com/115.html

2、静风博客                        http://www.jingfeng.info/archives/690.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值