
Download Next Page, Not Next Post at WordPress.org
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.
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.
It’s as simple as echo’ing the functions in your page:
<?php echo next_page_not_post(); ?> <?php echo previous_page_not_post(); ?>
<?php
$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.
Comments are closed