Title: Previous/Next post in same category
Last modified: August 22, 2016

---

# Previous/Next post in same category

 *  Resolved [demonboy](https://wordpress.org/support/users/demonboy/)
 * (@demonboy)
 * [12 years, 1 month ago](https://wordpress.org/support/topic/previousnext-post-in-same-category/)
 * I’ve amended template-tags.php in the inc folder to read:
 *     ```
       if ( ! function_exists( 'isola_paging_nav' ) ) :
       /**
        * Display navigation to next/previous set of posts when applicable.
        */
       function isola_paging_nav() {
       	// Don't print empty markup if there's only one page.
       	if ( $GLOBALS['wp_query']->max_num_pages < 2 ) {
       		return;
       	}
       	?>
       	<nav class="navigation paging-navigation" role="navigation">
       		<h1 class="screen-reader-text"><?php _e( 'Posts navigation', 'isola' ); ?></h1>
       		<div class="nav-links">
   
       			<?php if ( get_next_posts_link() ) : ?>
       			<div class="nav-previous"><?php next_posts_link( __( '<span class="meta-nav">&larr;</span> Older posts', 'isola', TRUE ) ); ?></div>
       			<?php endif; ?>
   
       			<?php if ( get_previous_posts_link() ) : ?>
       			<div class="nav-next"><?php previous_posts_link( __( 'Newer posts <span class="meta-nav">&rarr;</span>', 'isola', TRUE ) ); ?></div>
       			<?php endif; ?>
   
       		</div><!-- .nav-links -->
       	</nav><!-- .navigation -->
       	<?php
       }
       endif;
   
       if ( ! function_exists( 'isola_post_nav' ) ) :
       /**
        * Display navigation to next/previous post when applicable.
        */
       function isola_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', 'isola', TRUE ); ?></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', 'isola', TRUE ) );
       				next_post_link(     '<div class="nav-next">%link</div>',     _x( '%title <span class="meta-nav">&rarr;</span>', 'Next post link',     'isola', TRUE ) );
       			?>
       		</div><!-- .nav-links -->
       	</nav><!-- .navigation -->
       	<?php
       }
       endif;
       ```
   
 * The TRUE parameter should only link to the next post in the same category, but
   it isn’t, it’s being ignored.
 * Any clues?

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Moderator [Kathryn Presner](https://wordpress.org/support/users/zoonini/)
 * (@zoonini)
 * [12 years, 1 month ago](https://wordpress.org/support/topic/previousnext-post-in-same-category/#post-5272557)
 * Hi there, the function isola_paging_nav() isn’t meant for single-post navigation,
   but for displaying older/newer batches of posts on the blog index, for example.
   The function you’re looking for to navigate from post to post is isola_post_nav().
 * To set this up properly so your changes aren’t overwritten when you next update
   the theme, you’ll need to first create a child theme. Here are some guides in
   case you haven’t made one before:
 * [http://codex.wordpress.org/Child_Themes](http://codex.wordpress.org/Child_Themes)
   
   [http://op111.net/53/](http://op111.net/53/) [http://vimeo.com/39023468](http://vimeo.com/39023468)
 * In your child theme, create a new file in a plain-text editor called functions.
   php, and place this function at the top:
 *     ```
       <?php function isola_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', 'isola' ); ?></h1>
       		<div class="nav-links">
       			<?php previous_post_link( '<div class="nav-previous">%link</div>', 'Previous post in category', TRUE ); ?>
       			<?php next_post_link( '<div class="nav-next">%link</div>', 'Next post in category', TRUE ); ?>
       		</div><!-- .nav-links -->
       	</nav><!-- .navigation -->
       	<?php
       }
       ```
   
 * That should do it – I tested it on my end and it’s working. Let me know how it
   goes!
 *  Thread Starter [demonboy](https://wordpress.org/support/users/demonboy/)
 * (@demonboy)
 * [12 years, 1 month ago](https://wordpress.org/support/topic/previousnext-post-in-same-category/#post-5272576)
 * Yep, that did it. Once again, thank you, Kathryn.
 * Cheers,
 * Jamie
 *  Moderator [Kathryn Presner](https://wordpress.org/support/users/zoonini/)
 * (@zoonini)
 * [12 years, 1 month ago](https://wordpress.org/support/topic/previousnext-post-in-same-category/#post-5272613)
 * You’re very welcome.

Viewing 3 replies - 1 through 3 (of 3 total)

 The topic ‘Previous/Next post in same category’ is closed to new replies.

 * ![](https://i0.wp.com/themes.svn.wordpress.org/isola/1.0.9/screenshot.png)
 * Isola
 * [Support Threads](https://wordpress.org/support/theme/isola/)
 * [Active Topics](https://wordpress.org/support/theme/isola/active/)
 * [Unresolved Topics](https://wordpress.org/support/theme/isola/unresolved/)
 * [Reviews](https://wordpress.org/support/theme/isola/reviews/)

## Tags

 * [category](https://wordpress.org/support/topic-tag/category/)
 * [next](https://wordpress.org/support/topic-tag/next/)
 * [previous](https://wordpress.org/support/topic-tag/previous/)

 * 3 replies
 * 2 participants
 * Last reply from: [Kathryn Presner](https://wordpress.org/support/users/zoonini/)
 * Last activity: [12 years, 1 month ago](https://wordpress.org/support/topic/previousnext-post-in-same-category/#post-5272613)
 * Status: resolved