I am currently developing a portfolio section on my website and when the single posts are viewed, there are some previous and next links to take the user to the next post.

Upon reaching the first post single view, the previous button takes the user to the fifth post in the series rather than looping to number 12 in the series as expected.

Here is the code I used to generate the previous and next buttons,

<div class="five columns portfolio-nav">
   <li><?php previous_post_link('%link'); ?></li>
   <li><a href="<?php echo get_permalink( 187 ); ?>" class="backportfolio">My link</a></li>
   <li><?php next_post_link('%link'); ?></li>

the portfolio test site is at http://sandpit.jonathanbeech.co.uk/portfolio-two/

Is there a way of configuring these buttons to allow them to move to the appropriate post

  • What "series" are you talking about? What order do you expect?
    – s_ha_dum
    Commented Jul 4, 2013 at 15:23
  • On the portfolio page with the 12 examples of work, the posts run in a specific order from left to right. the trouble I am having is that there is a previous button within the single page view when you click on the continue reading button of the first post on the main portfolio page. The previous button takes the user to the fifth post in that series which is unexpected. I did use a plugin called post types order which may be creating problems but I cant be sure at this stage. Hope this clarifies things. Commented Jul 4, 2013 at 15:37

2 Answers 2


You could try the following plugin:

It is very customizable in terms of link options and should, as far as I can see, do the job for you. I have very good experience using it up to WP 3.5.

  • You're welcome! Btw - for your interest or anyboby else stumbling over this question - you can learn alot about the handling of previous_post_link, next_post_link, get_adjacent_post and so by looking at the code of the plugin - I certainly did. That would be going in the direction @s_ha_dum noted - i.e. the post link query and handling the related filters and so on. Commented Jul 4, 2013 at 19:30

The previous_post_link functions and next_post_link functions run their own query to get the links. The sort order is assumed to be by date, and they don't know anything about your "specific order".

There are filters that you can use to alter the query but without knowing exactly how your post order works on a database level I couldn't write the code (and it could well be pretty tricky to write anyway).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.