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.

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

2 Answers 2

<?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

 
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.