Next and previous link in custom post type in the same taxonomy term

previous_post_link() and next_post_link() work perfectly with custom post types. You need to paste this code in your single-customposttype.php (which in your case is single-portfolio.php):

<div class="previous-post-link">
                <?php previous_post_link('%link', '<< Previous Post', $in_same_term = true, $excluded_terms="", $taxonomy = 'the-custom-taxonomy-associated-with-your-custom-post-type'); ?>                    
            </div>

            <div class="next-post-link">
                <?php next_post_link('%link', 'Next Post >>', $in_same_term = true, $excluded_terms="", $taxonomy = 'the-custom-taxonomy-associated-with-your-custom-post-type'); ?>                    
            </div> 

Leave a Comment