stay in category

Stay in Category

The text of this article is also in a pastebin – http://pastebin.com/4fLC9FLy

In many themes, the previous/next_post_link in single.php does not stay in category. If you view a category archive, then select a single post, the prev/next link may not show a post in the same category.

If you set the ‘in_same_cat’ parameter to the previous/next_post_link calls in single.php to ‘true’, single.php will stay in category provided the posts belong only to one category. If posts belong to more than one category, the prev/next links may point to posts in one of the categories other than the one from the category archive. Changing ‘in_same_cat’ will also affect how a blog works, because you normally don’t want to stay in category when coming from a blog post list.
Continue reading