Quantcast
Channel: 行畔博客 »摘要
Viewing all articles
Browse latest Browse all 2

请不要怀疑我的文章views

$
0
0

行畔博客使用的是经典的inove主题,喜欢它的简单易用,当然还有经典这一特质。当初它被用于WordPress默认主题的inove主题,在我眼里,inove风采依旧。可是,没有什么是完美的,inove难逃一劫。

所以,接手inove主题后,我就开始着手加工主题,包括加入一些插件,修改某些代码,从而使得主题从缺省状态,被修改成喜欢的风格样式,而新加入的功能也使得这一主题赶上了现在主流WordPress主题的步伐。

最近,我就发现了inove主题不能在首页显示文章的views(阅读数),仅仅只有评论数。在我眼里,views也是一个相当重要的指标。可以从views中看出文章的热度。inove缺少了这一功能实在可惜。于是,我通过Google的方式搜到了一些修改方法,现在将这些方法统一整理起来分享给大家参考,若有问题,请指正。

1.安装 wp-postviews 插件,至于插件的安装过程,这里略过;

2.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> <a href ><?php if(function_exists(‘the_views’)) { the_views(); } ?></a></span>

3.编辑inove主题下的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>

4.进入WordPress控制面板,将wp-postviews插件启用,并到设置里,进入 PostView 选项,进行相关的修改即可。

PS.下图是我修改以后显示的主页文章的摘要显示情况,看上去会发现,评论数比阅读数高,这是因为我刚刚修改的代码,所以统计从现在开始。不要怀疑我的文章views准确性哦,哈哈~~

文章的views情况

 


Viewing all articles
Browse latest Browse all 2

Latest Images

Trending Articles





Latest Images