Next and Previous Links for same Category in WordPress

I created a category and call it “WordPress”. Then I created some posts and assign “WordPress” as category for the posts. Now I want the next/previous to be shown for the same category only.

WordPress version

  • WordPress 3.5


  • function previous_post_link($format=’« %link’, $link=’%title’, $in_same_cat = false, $excluded_categories = ”)

You can change the in_same_cat to true to display the previous post in same cateogry.

Similarly you can show next post in the same category.

Source File

  • previous_posts_link() is located in wp-includes/link-template.php.
  • next_post_link() is located in wp-includes/link-template.php.

No comments yet.

Leave a Reply