WordPress.org

Forums

Trouble with page navigation for single posts (1 post)

  1. theflyingant
    Member
    Posted 10 months ago #

    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;

Reply

You must log in to post.

About this Topic

  • RSS feed for this topic
  • Started 10 months ago by theflyingant
  • This topic is not resolved
  • WordPress version: 3.9.1