Show Previous/Next Posts navigation only inside the same category

The functions accept an $in_same_cat argument, the default value of which is false. Just set that to true.

previous_post_link($format, $link, true);
next_post_link($format, $link, true);

Leave a Comment