Scrolling through a single category

While building a way was needed to stay within the Catalogue category and not get posts from the already sold items in the Portfolio category.

The site uses the included theme twentyeleven and the file to be changed is single.php

<nav id="nav-single">

<h3><?php _e( 'Post navigation', 'twentyeleven' ); ?></h3>
<span><?php previous_post_link( '%link', __( '<span>&larr;</span> Previous', 'twentyeleven' ),TRUE ); ?></span>
<span><?php next_post_link( '%link', __( 'Next <span>&rarr;</span>', 'twentyeleven' ),TRUE ); ?></span>

</nav><!-- #nav-single -->

The previous_post_link() and next_post_link() can be set to stay within the same category if the third parameter is set to true as can be seen in the above example. The highlighted text is what needs to be added.


Leave a Reply