Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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">
 <ul>
   <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>
 </ul>
</div>

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

share|improve this question
    
What "series" are you talking about? What order do you expect? –  s_ha_dum Jul 4 '13 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. –  Jonathan Beech Jul 4 '13 at 15:37

2 Answers 2

up vote 0 down vote accepted

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.

share|improve this answer
    
Just what I needed. Thankyou! –  Jonathan Beech Jul 4 '13 at 18:46
    
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. –  ialocin Jul 4 '13 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).

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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