Posted By

fedek6 on 04/21/14


Tagged

url wordpress navigation next previous posts


Versions (?)

URL's to next and previous posts in category


 / Published in: PHP
 

This snippet shows you how to get previous and next post in category URL.

  1. <!-- prev post in category -->
  2. <?php $prev = get_permalink(get_adjacent_post(false,'',false));
  3. if($prev != get_permalink()) { ?><a id="navi-left" href="<?php echo $prev; ?>"></a><?php } ?>
  4.  
  5. <!-- next post in category -->
  6. <?php $next = get_permalink(get_adjacent_post(false,'',true));
  7. if($next != get_permalink()) { ?><a id="navi-right" href="<?php echo $next; ?>"></a><?php } ?>

Report this snippet  

You need to login to post a comment.