Next Page, Not Next Post – WordPress Plugin


Download Next Page, Not Next Post at

Out of the box WordPress does a magnificent job of handling navigation between next & previous posts. It doesn’t do too great of a job handling navigation between sibling pages. We needed a solution to allow users to easily switch between these pages. After much searching and testing, it was clear that there wasn’t a good solution to this dilemma.

Our first “official” WordPress plugin “Next Page, Not Next Post” handles that without too much trouble.

An example solution

  • Home
  • About
    • Team
      • A
      • B
      • C
      • D
      • E
      • F

When a user is viewing page B, we create links to A & C. When on C, they get B & D and so on.

This plugin gives you two new functions, next_page_not_post($anchor_text, $loop, $getPages) & previous_page_not_post($anchor_text, $loop, $getPages). Each function has three simple options.

  1. Anchor Text – Either set the anchor text manually or use the page title. %title will be replaced with page title. Defaults to page title, just leave blank for that.
  2. Looping – Link the first element to the last and the last to the first, or not. Set this parameter to ‘expand’ and the plugin will descend into child pages and ascend into parent pages when needed. This is useful for creating a simple click-thru interface with multiple levels. Set to ‘cousins’ or ‘cousinsloop’ to click through pages with a similar grandparent. Defaults to not looping (set to false or NULL), set to true for looping.
  3. Get Pages – This is used with WordPress’s get_pages() function to determine the order of your pages. Defaults to menu_order and ascending.

It’s as simple as echo’ing the functions in your page:

<?php echo next_page_not_post(); ?>
<?php echo previous_page_not_post(); ?>

You can get more complex with this if needed in your templates. Setup a variable and then check if it’s empty to display more complex HTML. Maybe something along these lines?

 $nextPage = next_page_not_post('Next Page', 'true', 'sort_column=post_date&sort_order=desc');
 $prevPage = previous_page_not_post('Previous Page', 'true', 'sort_column=post_date&sort_order=desc');

 if (!empty($nextPage) || !empty($prevPage)) {
 echo '
<ul id="nextPrevPages">';

 if (!empty($nextPage)) echo '
 <li class="next">'.$nextPage.'</li>
 if (!empty($prevPage)) echo '
 <li class="previous">'.$prevPage.'</li>

 echo '</ul>


Just added 2 shortcodes to help users that aren’t able to edit their theme files. The two shortcodes are [ next_page ] and [ previous_page ]. Each supports 3 attributes: anchor, loop and getPagesQuery. Each attribute should function the same as the function documentation above.

Let us know if this plugin works for you or you have any ideas for improving it.

Special thanks to Sarah & Frodo for help with testing.


  • 0.2.0: Patched title’s with special characters breaking output
  • 0.1.8: Added ‘cousin’ & ‘cousinloop’ to the looping options, development sponsored by Funkhaus Design 
  • 0.1.7: Fixed grandparent ascension in expand looping and added %title to anchor parameter
  • 0.1.6: Added shortcodes
  • 0.1.5: Added title attribute to links
  • 0.1.4: Added the ability to ascend and descend into parent/child pages.
  • 0.1.3: Replaced the manual sort option with more robust, $getPages option.
  • 0.1.2: Added the ability to manually sort.
  • 0.1.1: Updated plugin to work with “ugly” URLs.
  • 0.1: We’re still in early development with this plugin. There are bound to be some bugs and improvements we can implement.

Please use the Support Forum for assistance with this plugin.

Comments are closed