このブログにページナビゲーションプラグイン
WP-PageNavi
をインストールしました。
プラグインのインストール、有効化の後に
テーマのソースを変更が必要となります。
このサイトで使用しているテーマ twentytwelve での変更は
functions.phpを以下のように変更しす。
変更前
275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 | if ( ! function_exists( 'twentytwelve_content_nav' ) ) : /** * Displays navigation to next/previous pages when applicable. * * @since Twenty Twelve 1.0 */ function twentytwelve_content_nav( $html_id ) { global $wp_query; $html_id = esc_attr( $html_id ); if ( $wp_query->max_num_pages > 1 ) : ?> <nav id="<?php echo $html_id; ?>" class="navigation" role="navigation"> <h3 class="assistive-text"><?php _e( 'Post navigation', 'twentytwelve' ); ?></h3> <div class="nav-previous"><?php next_posts_link( __( '<span class="meta-nav">←</span> Older posts', 'twentytwelve' ) ); ?></div> <div class="nav-next"><?php previous_posts_link( __( 'Newer posts <span class="meta-nav">→</span>', 'twentytwelve' ) ); ?></div> </nav><!-- #<?php echo $html_id; ?> .navigation --> <?php endif; } endif; |
変更後
275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 | if ( ! function_exists( 'twentytwelve_content_nav' ) ) : /** * Displays navigation to next/previous pages when applicable. * * @since Twenty Twelve 1.0 */ function twentytwelve_content_nav( $html_id ) { global $wp_query; $html_id = esc_attr( $html_id ); if ( $wp_query->max_num_pages > 1 ) : ?> <nav id="<?php echo $html_id; ?>" class="navigation" role="navigation"> <h3 class="assistive-text"><?php _e( 'Post navigation', 'twentytwelve' ); ?></h3> <?php wp_pagenavi(); ?> </nav><!-- #<?php echo $html_id; ?> .navigation --> <?php endif; } endif; |