之前提到我换了个主题——ProwerV6,但是,这个主题有点不好,它的 PageNavi 样式使用的是“Older Posts”和“Newer Posts”,而不是“PageNavi”,这显然不利于我们翻页查找。所以,我就给它添加了“PageNavi”。
添加方法:
1)修改主题的 Style.css,加入:
.page-numbers {font-weight:700; font-size:1.2em; line-height:34px; border-radius:20px; display:inline-block; width:34px; height:34px; margin:0 0.5em; text-decoration:none;} .page-numbers {border:1px solid #333; color:#fff; background-color:#444; text-shadow:1px 1px #111; background-image:-webkit-linear-gradient(#444,#222); background-image:-moz-linear-gradient(#444,#222); background-image:-ms-linear-gradient(#444,#222); background-image:-o-linear-gradient(#444,#222); background-image:linear-gradient(#444,#222); box-shadow:0 1px 0 #fff,1px 0 0 #fff,-1px 0 0 #fff,0 -1px 0 #fff,inset 0 1px 0 #888; }
2)修改主题的 Functions.php,加入:
<?php function nikbobo_pagenavi() { global $wp_query; $big = 999999999; // need an unlikely integer $pagination = array( 'base' => str_replace($big, '%#%', get_pagenum_link( $big )), 'format' => '', 'total' => $wp_query->max_num_pages, 'current' => max(1, get_query_var('paged')), 'prev_text' => '<', 'next_text' => '>', 'show_all' => false, 'end_size' => 1, 'mid_size' => 1 ); echo paginate_links($pagination); } ?>
3)修改主题的 Index.php,查找:
<?php previous_posts_link(('<')) ?><?php next_posts_link(('>')) ?>
替换为:
<?php nikbobo_pagenavi(); ?>
大功告成!