项目要求:
实现 某个分类下的文章标题列表的分页显示
step1
<?php if ( have_posts() ) : ?>
<header class="page-header">
<h1 class="page-title"><?php
printf( __( 'Category Archives: %s', 'encoaching' ), '<span>' . single_cat_title( '', false ) . '</span>' );
?></h1>
<?php
$category_description = category_description();
if ( ! empty( $category_description ) )
echo apply_filters( 'category_archive_meta', '<div class="category-archive-meta">' . $category_description . '</div>' );
?>
</header>
<?php /* Start the Loop */?>
<ul>
<?php $postcount=0 ;while ( have_posts() ) :the_post(); $postcount++; ?>
<?php endwhile;?>
<?php while ( have_posts() ) : the_post(); ?>
<?php if($postcount >1):?>
<li>
<a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>">
<?php the_title();?>
</a>
<span>Written at <?php the_time('Y-m-d');?></span>
</li>
<? endif;?>
<?php endwhile;?>
</ul>
<div class="navigation">
<?php /* if ( function_exists( 'page_navi' ) ) page_navi(); */?>
<?php if ( function_exists( 'page_navi' ) ) page_navi( 'items=7&prev_label=Prev&next_label=Next&first_label=First&last_label=Last&show_num=1&num_position=after' ); ?>
</div>
<?php if($postcount == 1):the_post();?>
<?php get_template_part( 'content', get_post_format() );?>
<?php endif; ?>
<?php else : ?>
step2
添加如下插件
Prime Strategy Page Navi 然后启用
step3
添加如下样式
<style>
.page_navi {
text-align: center;
}
.page_navi li {
display: inline;
list-style: none;
}
.page_navi li.current span {
color: #000;
font-weight: bold;
display: inline-block;
padding: 3px 7px;
background: #fee;
border: solid 1px #fcc;
}
.page_navi li a {
color: #333;
padding: 3px 7px;
background: #eee;
display: inline-block;
border: solid 1px #999;
text-decoration: none;
}
.page_navi li a:hover {
color: #f00;
}
.page_navi li.page_nums span {
color: #fff;
padding: 3px 7px;
background: #666;
display: inline-block;
border: solid 1px #333;
}
</style>