安装并启用插件 WP-PostViews
修改content.php
<div class="entry-meta"> <?php if ( 'post' == get_post_type() ) twentyfourteen_posted_on(); if ( ! post_password_required() && ( comments_open() || get_comments_number() ) ) : ?> <span class="comments-link"><?php comments_popup_link( __( 'Leave a comment', 'twentyfourteen' ), __( '1 Comment', 'twentyfourteen' ), __( '% Comments', 'twentyfourteen' ) ); ?></span> <?php endif; edit_post_link( __( 'Edit', 'twentyfourteen' ), '<span class="edit-link">', '</span>' ); ?> </div><!-- .entry-meta -->
修改为
<?php if ( 'post' == get_post_type() ) twentyfourteen_posted_on(); if ( ! post_password_required() && ( comments_open() || get_comments_number() ) ) : ?> <span class="comments-link"><?php comments_popup_link( __( 'Leave a comment', 'twentyfourteen' ), __( '1 Comment', 'twentyfourteen' ), __( '% Comments', 'twentyfourteen' ) ); ?></span> <?php endif; edit_post_link( __( 'Edit', 'twentyfourteen' ), '<span class="edit-link">', '</span>' ); ?> <?php if(function_exists('the_views')) { the_views(); } ?> </div><!-- .entry-meta -->
在侧边栏显示浏览最高的10篇文章
在主题的sidebar.php中的对应位置加入
<?php if (function_exists('get_most_viewed')): ?> <?php get_most_viewed('post',10); ?> <?php endif; ?>