Title: Automatic Next/Previous Pages
Last modified: July 10, 2021

---

# Automatic Next/Previous Pages

 *  Resolved [ryina](https://wordpress.org/support/users/ryina/)
 * (@ryina)
 * [4 years, 10 months ago](https://wordpress.org/support/topic/automatic-next-previous-pages/)
 * Hi,
    I’m wondering if there is a plugin that will automatically create and update
   Next/Previous buttons at the bottom of a page that sorts by Category.
 * Towards the bottom of the post in the link I added, you can see the Previous/
   TOC/Next buttons and these buttons are currently manually added. Is there something
   that will automatically add them and sort by category?
 * I want something similar to the “Next post/previous post” button that wordpress
   automatically generates but specific to certain categories.
 * For example, every time I post something in the category “The Interstellar Male
   God” the button will update to the next post and only to posts in that category.
 * The reason I need this is because I post stories by chapters. I want to update
   two different stories, but want the buttons to only connect to the chapters in
   its own story.
 * Thanks in advance!
    -  This topic was modified 4 years, 10 months ago by [Jan Dembowski](https://wordpress.org/support/users/jdembowski/).
      Reason: Moved to Fixing WordPress, this is not an Developing with WordPress
      topic
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fautomatic-next-previous-pages%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

Viewing 2 replies - 1 through 2 (of 2 total)

 *  [rickymccallum87](https://wordpress.org/support/users/rickymccallum87/)
 * (@rickymccallum87)
 * [4 years, 10 months ago](https://wordpress.org/support/topic/automatic-next-previous-pages/#post-14646955)
 * The function [get_the_post_navigation()](https://developer.wordpress.org/reference/functions/get_the_post_navigation/)
   has an `in_same_term` argument which makes this possible.
 * In your theme (Astra), there’s a filter hook for the navigation arguments called`
   astra_single_post_navigation`. So this code hooks onto that and updates it to
   the behavior you want.
 * You can place this in your functions.php file or use the [Code Snippets Plugin](https://wordpress.org/plugins/code-snippets/).
 *     ```
       add_filter('astra_single_post_navigation', 'wpsf_category_pagination');
       function wpsf_category_pagination($args)
       {
         $args['in_same_term'] = true;
         return $args;
       }
       ```
   
 *  Thread Starter [ryina](https://wordpress.org/support/users/ryina/)
 * (@ryina)
 * [4 years, 10 months ago](https://wordpress.org/support/topic/automatic-next-previous-pages/#post-14647390)
 * That’s exactly what I’m looking for. Thank you!

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Automatic Next/Previous Pages’ is closed to new replies.

## Tags

 * [next previous](https://wordpress.org/support/topic-tag/next-previous/)
 * [same category](https://wordpress.org/support/topic-tag/same-category/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 2 replies
 * 2 participants
 * Last reply from: [ryina](https://wordpress.org/support/users/ryina/)
 * Last activity: [4 years, 10 months ago](https://wordpress.org/support/topic/automatic-next-previous-pages/#post-14647390)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
