WordPress pagination based on category

The functions next_post_link() and previous_post_link() have the parameters $in_same_term and $taxonomy for that purpose.