WordPress.org

Ready to get started?Download WordPress

Forums

WP-PageNavi
How To Add PageNavi to Twenty Thirteen to WordPress Theme (3 posts)

  1. Chester
    Member
    Posted 7 months ago #

    Hi, I am using Twenty Thirteen child theme. Need help to implement WP-PageNavi on Twenty Thirteen. Actually i am not a coder. Found no solution to implement on Twenty Thirteen in support forum.

    http://wordpress.org/plugins/wp-pagenavi/

  2. Chester
    Member
    Posted 7 months ago #

    I found the solution. Got the code

    <div class="nav-previous"><?php next_posts_link( __( '<span class="meta-nav">←</span> Older posts', 'twentythirteen' ) ); ?></div>
    <div class="nav-next"><?php previous_posts_link( __( 'Newer posts <span class="meta-nav">→</span>', 'twentythirteen' ) ); ?></div>

    in line no 268 in my functions.php file in twenty thirteen theme which is to be replaced with <?php wp_pagenavi(); ?> according to its documentation. but i had to replace the whole block of code looks like

    <?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; ?>

    i just wants to ask is there any problem to replace the whole block? Will this affect any other functions in my site?

  3. Aleksandra Sasha
    Member
    Posted 6 months ago #

    Create a child theme, add a functions.php and add this

    // WP-PageNavi
    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 wp_pagenavi(); ?>
    
    		</div><!-- .nav-links -->
    	</nav><!-- .navigation -->
    	<?php
    }

Reply

You must log in to post.

About this Plugin

About this Topic

Tags

No tags yet.