This plugin provides shortcodes and template tags for next/previous navigation in pages. This plugin is no longer supported! If you would like to adopt it, please get in touch.
download at wordpress.org get support at wordpress.org donate to future development
If you’d rather not deal with the overhead of a plugin, here’s the condensed code for your page template file:
<?php $pagelist = get_pages('sort_column=menu_order&sort_order=asc'); $pages = array(); foreach ($pagelist as $apage) { $thepages[] += $apage->ID; } $current = array_search($post->ID, $thepages); $prevID = $thepages[$current-1]; $nextID = $thepages[$current+1]; ?> <div class="navigation"> <?php if (!empty($prevID)) { ?> <div class="alignleft"> <a href="<?php echo get_permalink($prevID); ?>" title="<?php echo get_the_title($prevID); ?>">Previous</a> </div> <?php } if (!empty($nextID)) { ?> <div class="alignright"> <a href="<?php echo get_permalink($nextID); ?>" title="<?php echo get_the_title($nextID); ?>">Next</a> </div> <?php } ?> </div><!-- .navigation -->
You can emulate Drupal’s book feature and include a link to the page parent as well:
<div class="aligncenter"> <a href="<?php echo get_permalink($post->post_parent); ?>" title="<?php echo get_the_title($post->post_parent); ?>">Up one level</a> </div>
Version 1.2 adds an option to exclude pages by ID. You can simply add the exclude parameter to the get_pages()
function in your template code:
$pagelist = get_pages('sort_column=menu_order&sort_order=asc&exclude=6,21,47');