• Skip to primary navigation
  • Skip to main content
  • Skip to footer
  • Books
    • Content Strategy for WordPress (2015)
    • WordPress for Web Developers (2013)
    • Beginning WordPress 3 (2010)
  • Blog
    • Content Modeling for WordPress
    • WordPress Hidden Gems
    • Web Design
  • Work
    • Presentations and Interviews
    • on GitHub →
    • MLIS Class Projects (2019-2022)
    • Portfolio (2002-2019)
    • WordPress Plugins

Stephanie Leary

Writer, Front End Developer, former WordPress consultant

  • About
    • Press Kit
    • Presentations and Interviews
  • Contact Me

Previous and Next links for pages

July 5, 2009 Stephanie Leary Leave a Comment

Next Page options screen

Ever want to let your visitors browse your pages in order? You’ve probably discovered that previous_posts_link and next_posts_link don’t work on pages.

I’ve written a plugin, Next Page, to solve the problem. You’ll get an options screen allowing you to specify the language of your links.

If you’d rather not deal with a plugin, here’s the code you need to add to your page template. I’ve left in a few lines to help with debugging. If your links don’t lead to the pages you expect, you can uncomment those lines to see what’s going on.

ID;
}

//print_r($pages);

$current = array_search($post->ID, $thepages);
$prevID = $thepages[$current-1];
$nextID = $thepages[$current+1];

/*
echo “Current page ID’s array key: $current”;
echo “Previous page ID: $prevID”;
echo “Next page ID: $nextID”;
*/
?>

Drupal’s book feature and include a link to the page parent as well:

-->

WordPress Navigation, page order, Permalinks

This is an excerpt from Content Strategy for WordPress.My latest books are Content Strategy for WordPress (2015) and WordPress for Web Developers (2013). Sign up to be notified when I have a new book for you.

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Footer

My Books

I’m a front end developer at Equinox OLI, working on open source library software. I was previously a freelance WordPress developer in higher education. You can get in touch here or on LinkedIn.

Copyright © 2025 Stephanie Leary · Contact