Custom Next/Previous links on posts
-
Hello –
I have a small problem with some custom next/previous post links I’m using – Here’s the code:
<?php $next_post = get_next_post(); $prev_post = get_previous_post(); ?> <a href="<?php echo get_permalink($prev_post->ID);?>" title="<?php echo str_replace('"', '\'', $prev_post->post_title); ?>" class="">« Previous post<br /><strong>"<?php echo str_replace('"', '\'', $prev_post->post_title); ?>"</strong></a> <a href="<?php echo get_permalink($next_post->ID);?>" title="<?php echo str_replace('"', '\'', $next_post->post_title); ?>" class="">Next post »<br /><strong>"<?php echo str_replace('"', '\'', $next_post->post_title); ?>"</strong></a>
The problem is that when you’re at the most recent post, the Next Post will link to itself (current/most recent post). How can I hide the “Next Post” link altogether when on the most recent post?
(note- this also happens on the most Previous post)
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Custom Next/Previous links on posts’ is closed to new replies.