WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

how can I disable "previous link" in first post and "next link" in last post? thank you

share|improve this question
ooops sorry... I mean: Disable “previous link” in FIRST post and “next link” in LAST post – Dee Jul 2 '11 at 8:19
<?php next_post_link('format', 'link', 'in_same_cat', 'excluded_categories'); ?> 

<?php previous_post_link($format, $link, $in_same_cat = false, $excluded_categories = ''); ?>
share|improve this answer
not to show the link in this situation is imho the default bahaviour of next_post_link() (and 'prev' resp) – Michael Jul 2 '11 at 11:14
@:Michael sorry friend,i can't get you.will you explain little bit more?' – Ramkumar Jul 2 '11 at 11:24
your latest edit is nearly what i was talking about: the genuine wordpress functions next_post_link() and previous_post_link() (singular 'post' not 'posts') don't show for the first and last post, resp. – Michael Jul 2 '11 at 11:34
@:Michael,thanks for pointing out.am little confused with this function. – Ramkumar Jul 2 '11 at 11:40

Just use this, no extra functions required:

<div class="previous-post"> <?php previous_post_link(' &laquo;%link ') ?> </div>
<div class="next-post"> <?php next_post_link(' %link &raquo; ') ?> </div>

Just add this to the single.php, not the index.php. This is the simple way to show in single posts only (this won't show the prev. post link on the last post, on the first post there won't be a next post).

share|improve this answer

Your Answer


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.