• Hi,

    I’m getting confused trying to add post navigation to single post. I want to be able to move to next/previous post. The individual post has been selected from a list of posts sharing the same custom taxonomy term. I’m attempting to add pagination using
    <?php $theme_post_nav(); ?> function below (from underscores theme). The links appear, but instead of moving forward and backwards by 1 post, they jump by 20. I can’t understand why? I’m sure I’m missing something obvious – can anyone explain?

    if ( ! function_exists( '$theme_post_nav' ) ) :
    /**
     * Display navigation to next/previous post when applicable.
     */
    function $theme_post_nav() {
    	// Don't print empty markup if there's nowhere to navigate.
    	$previous = ( is_attachment() ) ? get_post( get_post()->post_parent ) : get_adjacent_post( false, '', true );
    	$next     = get_adjacent_post( false, '', false );
    
    	if ( ! $next && ! $previous ) {
    		return;
    	}
    	?>
    	<nav class="navigation post-navigation" role="navigation">
    		<h1 class="screen-reader-text"><?php _e( 'Post navigation', '$theme' ); ?></h1>
    		<div class="nav-links">
    			<?php
    				previous_post_link( '<div class="nav-previous">%link</div>', _x( '<span class="meta-nav">&larr;</span> %title', 'Previous post link', '$theme' ) );
    				next_post_link(     '<div class="nav-next">%link</div>',     _x( '%title <span class="meta-nav">&rarr;</span>', 'Next post link',     '$theme' ) );
    			?>
    		</div><!-- .nav-links -->
    	</nav><!-- .navigation -->
    	<?php
    }
    endif;
  • The topic ‘Trouble with page navigation for single posts’ is closed to new replies.