Twenty Twelve 虽作为 WordPress 官方主题,但是我并不喜欢,我觉得那样的配套,老土、难看。但是,有人要我弄出 Page Navi,而不是采用传统方式。我也弄一下把!
1)修改主题 Style.CSS,加入:
.page-numbers { font-size: 26px !important; padding: 0 2px 2px; }
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' => '<span class="meta-nav">←</span>', 'next_text' => '<span class="meta-nav">→</span>', 'show_all' => False, 'end_size' => 1, 'mid_size' => 1 ); echo paginate_links($pagination); } ?>
3)在主题的 Functions.php,查找:
function twentythirteen_paging_nav() { global $wp_query; // Don't print empty markup if there's only one page. if ( $wp_query->max_num_pages < 2 ) return; ?> <nav class="navigation paging-navigation" role="navigation"> <h1 class="screen-reader-text"><?php _e( 'Posts navigation', 'twentythirteen' ); ?></h1> <div class="nav-links"> <?php if ( get_next_posts_link() ) : ?> <div class="nav-previous"><?php next_posts_link( __( '<span class="meta-nav">←</span> Older posts', 'twentythirteen' ) ); ?></div> <?php endif; ?> <?php if ( get_previous_posts_link() ) : ?> <div class="nav-next"><?php previous_posts_link( __( 'Newer posts <span class="meta-nav">→</span>', 'twentythirteen' ) ); ?></div> <?php endif; ?> </div><!-- .nav-links --> </nav><!-- .navigation --> <?php }
替换为:
function twentythirteen_paging_nav() { global $wp_query; // Don't print empty markup if there's only one page. if ( $wp_query->max_num_pages < 2 ) return; ?> <nav class="navigation paging-navigation" role="navigation"> <h1 class="screen-reader-text"><?php _e( 'Posts navigation', 'twentythirteen' ); ?></h1> <div class="nav-links"> <?php nikbobo_pagenavi(); ?> </div><!-- .nav-links --> </nav><!-- .navigation --> <?php }
大功告成!
有没有发现?这其实和我之前的 ProwerV6 主题添加 WordPress PageNavi 教程 和 Twenty Twelve 主题添加 WordPress PageNavi 教程 是差不多的,唯一的区别就是 CSS。
话说,Twenty Thirteen 的 CSS,我也弄出来了,有时间再发吧!