0

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

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

<?php previous_post_link($format, $link, $in_same_cat = false, $excluded_categories = ''); ?>
  • 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 M 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 M Jul 2 '11 at 11:40
1

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).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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