URL's to next and previous posts in category


/ Published in: PHP
Save to your folder(s)

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


Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.