Next and Previous links on a single taxonomy page only link to same term

I am currently using toolbox as a parent theme and have created a template file called single-projects.php where all posts of the custom post type ‘projects’ are shown. The previous and next buttons work well but they show the next posts in the same ‘projects’ post type and I need them to be in the same taxonomy as well. The code for the previous/next links now looks like this:

<nav id="nav-below">
  <div class="nav-previous"><?php previous_post_link( '%link', '<span class="meta-nav">' . _x( '&larr;', 'Previous post link', 'toolbox' ) . '</span> Previous Post' ); ?></div>
  <div class="nav-next"><?php next_post_link( '%link', 'Next Post <span class="meta-nav">' . _x( '&rarr;', 'Next post link', 'toolbox' ) . '</span>' ); ?></div>
</nav><!-- #nav-below -->

This post seemed the closest to what I need https://stackoverflow.com/questions/5775197/wordpress-get-pages-taxonomy-parameter but I could not get it to work. Is there a way to only link to posts in the same taxonomy?

1 Answer
1

This plugin will help you accomplish your goal: http://www.ambrosite.com/plugins/next-previous-post-link-plus-for-wordpress

Leave a Comment