/ Published in: PHP

This snippet shows you how to get previous and next post in category URL.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<!-- prev post in category --> <?php $prev = get_permalink(get_adjacent_post(false,'',false)); if($prev != get_permalink()) { ?><a id="navi-left" href="<?php echo $prev; ?>"></a><?php } ?> <!-- next post in category --> <?php $next = get_permalink(get_adjacent_post(false,'',true)); if($next != get_permalink()) { ?><a id="navi-right" href="<?php echo $next; ?>"></a><?php } ?>
Comments
