How To Add WP-PageNavi to Twenty Eleven WordPress Theme ?

PageNaviIs a WordPress Plugin that show page in your themes. It was a great plugin for me so far as I have many page on my blog. This post is all about how to add the WP-PageNavi to Twenty Eleven WordPress Theme. Easy and Straight forward.

(1) Open functions.php of twenty eleven

(2) Locate code as below

function twentyeleven_content_nav( $nav_id ) {
        global $wp_query;

        if ( $wp_query->max_num_pages > 1 ) : ?>
                <nav id="<?php echo $nav_id; ?>">
                        <h3 class="assistive-text"><?php _e( 'Post navigation', 'twentyeleven' ); ?></h3>
                        <div class="nav-previous"><?php next_posts_link( __( '<span class="meta-nav">←</span> Older posts', 'twentyeleven' ) ); ?></div>
                        <div class="nav-next"><?php previous_posts_link( __( 'Newer posts <span class="meta-nav">→</span>', 'twentyeleven' ) ); ?></div>
                </nav><!-- #nav-above -->

(3)after that line, replace div class=”nav-previous” and div class=”nav-next” with

<?php wp_pagenavi(); ?>

After edit, code will as below

function twentyeleven_content_nav( $nav_id ) {
        global $wp_query;

        if ( $wp_query->max_num_pages > 1 ) : ?>
                <nav id="<?php echo $nav_id; ?>">
                        <h3 class="assistive-text"><?php _e( 'Post navigation', 'twentyeleven' ); ?></h3>
                        <?php wp_pagenavi(); ?>
                </nav><!-- #nav-above -->

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>