1,在插件中搜索并安装WP-PostViews
2,按照插件的简介安装
1 2 3 4 5 6 7 |
Usage Open wp-content/themes/<YOUR THEME NAME>/index.php You may place it in archive.php, single.php, post.php or page.php also. Find: <?php while (have_posts()) : the_post(); ?> Add Anywhere Below It (The Place You Want The Views To Show): <?php if(function_exists('the_views')) { the_views(); } ?> Or you can use the shortcode [views] or [views id="1"] (where 1 is the post ID) in a post Go to WP-Admin -> Settings -> PostViews to configure the plugin. |
3,我是希望自动在我的主题中增加,所以修改vim themes/twentyfifteen/content.php,如下第3行
1 2 3 4 5 |
<footer class="entry-footer"> <?php twentyfifteen_entry_meta(); ?> <span class="cat-links"> <?php if(function_exists('the_views')) { the_views(); } ?> </span> <?php edit_post_link( __( 'Edit', 'twentyfifteen' ), '<span class="edit-link">', '</span>' ); ?> </footer><!-- .entry-footer --> |
4,这样可以显示在文章结尾,但是显示的是“4 views”需要修改成中文
后台 设置-》PostViews-》Views Template(修改这个模板即可)
0 条评论