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.

At the bottom of each post I need to either:

  • Offer a link to the next post (if the next post is published); or
  • Display the title of the next post with the date it will be published (if it's a future post)

Suggestions?

share|improve this question
    
You are trying to replace your post navigation with this? –  s_ha_dum Feb 2 '13 at 20:00

1 Answer 1

up vote 0 down vote accepted

Add these two where you want them to display within your single.php file. It will make the title of the post a link.

<?php previous_post_link(); ?>
<?php next_post_link(); ?>

EDIT: Sorry I missed the second part of your question about future posts. Here's what I would probably do. It's not tested, but will give you an idea.

$adjacent_post = get_adjacent_post(false,'',false) ;
if (get_post_status( $adjacent_post->ID ) == 'publish'){
    echo '<?php next_post_link(); ?>';
}
else {
    echo get_the_title($adjacent_post->ID).' | '. $adjacent_post->post_date;
}
share|improve this answer
    
Even if the next post is set for a future date? –  Brandon Durham Feb 2 '13 at 20:29
    
Sorry, I had bypassed that part of your question. This will check if the next post is published, and if not, it will echo the name and the post date. You can modify however you want, but should give you the idea. –  Jake Lisby Feb 2 '13 at 20:33

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.