DATE: 2017-10-13 18:50:04
关于如何安装使用postviews,网上有很多的例子。 官网对安装过程有详细的说明。
但是,官网说:
打开
wp-content/themes/<YOUR THEME NAME>/index.php
您也可以将其放在archive.php,single.php,post.php
或page.php
中。 找:<?php while (have_posts()) : the_post(); ?>
在其下方添加任何地方(您要显示的视图的地方):<?php if(function_exists('the_views')) { the_views(); } ?>
这里安装加代码后,效果其实是不好的。最好的效果在哪里设置呢? 不是设置index.php ,而是content.php。
要将
if(function_exists('the_views')) { the_views(); } echo " ";
这一行放在div
<div class="entry-meta">
内。效果才能达到图下的效果。
代码示例:
<div class="entry-meta">
<?php
if(function_exists('the_views')) { the_views(); } echo " ";
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 -->