WordPress next_posts_link() Broken?

I finally got around to diagnosing and fixing the “Previous Entries” and “Next Entries” broken links on my blog’s WordPress 2.5 platform. Since the very first post on this blog, the next_posts_link() and previous_posts_link() functions were not working as advertised and I didn’t know why. It has been on my list of bugs to fix for quite some time, so I finally devoted a little time this morning to silence the little nagging to-do item.

If you have an SEO-friendly WordPress blog you might have changed the permalink structure to create more human-readable URLs for each post. For example, the default WordPress post permalink is www.yourblog.com/?p=123, where 123 is the unique ID for that particular post. There are many plugins that allow you to create keyword-rich URLs that rewrite the p=123 into something like www.yourblog.com/your-sample-post/. Rewriting the permalinks for your blog posts could inadvertently disrupt other static URLs in your WordPress platform, such as the www.yourblog.com/page/2/ and www.yourblog.com/page/3/ pages that are accessed via the “Previous Entries” and “Next Entries” links. These pages hold your older posts that have been bumped off of the first page of your blog.

It’s a simple fix for a common problem. Within the Settings of your WordPress dashboard, click on the Permalink Redirect tab. Within the Permanent Redirect Manager, include the following line in the “Paths to be skipped” box:

/page/*

This tells your site not to try to rewrite any URLs in the /page/ directory. The * is a “wildcard” that basically means “anything”. You can substitute other directory paths in there that you don’t manage with the permalink redirect plugin that you may be using.

Hope this is helpful, and that it helps you check one more thing off of your to-do list.

Comments

  1. Jules says

    I just changed the permalink method to archives (or anything other than default) in the end (and after everything else had failed to work) and it worked fine after that.

    You put me on the right track though… cheers.

    J.

  2. says

    Cameron, thanks for posting the link to the solution that worked for you. WordPress is a great tool, but the wide variety of plugins and modifications can leave quite a few unintended consequences.

  3. shahz says

    is it just me or the new wordpress does not have the “Permanent Redirect Manager” or “Paths to be skippped”?

  4. says

    Unfortunately that doesn’t exist/work anymore in WP 7 or 8…

    I’m still trying to find a way to keep my page names (for SEO purpose I don’t want to use numbers) and get the previous / next page thing to work….

    One more thing to include in the next version, please, WordPress :o)

Leave a Reply

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>