I've been pouring over this problem that seems really minor, but I can't seem to solve it. I'm trying to make next/previous links that only link to the category that the post is in. This is for a custom post type called portfolio. This is the code I currently have on the content-portfolio page:
<?php next_post_link( '<div class="nav-previous">%link</div>', '<span class="meta-nav">' . _x( '←', 'Next post link', 'morphology' ) . '</span> %title'); ?>
<?php previous_post_link( '<div class="nav-next">%link</div>', '%title <span class="meta-nav">' . _x( '→', 'Previous post link', 'morphology' ) . '</span>'); ?>
I've seen some variations of the following, but I can't seem to edit it to get it to cooperate:
<?php next_post_link( '%link', 'Next post in category', TRUE ); ?>
Any advice as to how to make this work or what I'm doing wrong?
Update: I still haven't gotten a good solution to this, and nothing I've tried from the other top Google hits seem to be working. As soon as I say that in_same_term = true, the link disappears entirely. Based on the answer below, this is the code I'm using:
<?php next_post_link(
'<div class="nav-previous">%link</div>',
'<span class="meta-nav">' . _x( '←', 'Next post link', 'morphology' ) . '</span> %title', true, array(), 'portfolio'); ?>