tags:

views:

14

answers:

1

I've set up a WordPress navigation for my single.php template that gets the previous and next post's thumbnails like this:

    <?php
// Newer posts
$nails_next_post = get_next_post('%link', '', FALSE, 3 );  // Get the previous post
$nails_next_post_thumbnail = get_the_post_thumbnail($nails_next_post->ID); // Get thumbnail
?>

<?php if ($nails_next_post != null) : ?>
<div class="post-nav-next">

   <?php if ($nails_next_post_thumbnail != null): ?>
              <?php echo $nails_next_post_thumbnail; ?>
            <?php else : ?>
              <img src="<?php bloginfo('template_directory'); ?>/images/default-90x90.gif" />
            <?php endif; ?>

         <?php next_post_link('%link', 'Forward' , TRUE, 3 ); ?>

    </div>
<?php endif; ?>


<?php
// Older posts
$nails_prev_post = get_previous_post('%link', '', FALSE, 3 ); // Get the previous post
$nails_prev_post_thumbnail = get_the_post_thumbnail($nails_prev_post->ID); // Get thumbnail
?>

<?php if ($nails_prev_post != null) : ?>
<div class="post-nav-previous">

   <?php if ($nails_prev_post_thumbnail != null): ?>
              <?php echo $nails_prev_post_thumbnail; ?>
            <?php else : ?>
              <img src="<?php bloginfo('template_directory'); ?>/images/default-90x90.gif" />
            <?php endif; ?>

         <?php previous_post_link('%link', 'Back' , TRUE, 3 ); ?>

    </div>
<?php endif; ?>

The problem I am having is that the links continue to point to the next or previous post in the current post's category, rather than just the next or previous post in the chronology (except posts in category 3 of course). I'm out of my deoth here. Does anyone have any thoughts? Thanks :-)

+1  A: 

I think you are using the wrong parameters on the get_next_post and get_previous_post functions. You probably accidentally used the parameters which go with next_post_link/previous_post_link

You only need two parameters and both are optional: http://codex.wordpress.org/Function_Reference/get_next_post

Simply try this:

$nails_next_post = get_next_post();
sprain
Ahhh, I did try that... must be tiredness. Thanks for the second set of eyes and for making the effort Sprain :-)
Niels Oeltjen
You're welcome. You could mark this question as answered now :)
sprain