I’ve seen this snippet of code flying around the Internet since yesterday and I’ve finally got a chance to blog about it.
Page navigation can become very tricky with wordpress especially when you’re doing custom query_posts() calls, but even the basics can be tricky and it’s not always best to simply use the built in next_posts_link() and previous_posts_link() to fulfill your requirements.
Here’s some code, which proves a lot better:
<?php if ($paged > 1) { ?>
<div class=”navigation”>
<div class=”alignleft”><?php next_posts_link(‘« Older Entries’) ?></div>
<div class=”alignright”><?php previous_posts_link(‘Newer Entries »’) ?></div>
</div>
<?php } else { ?>
<div class=”navigation”>
<div class=”alignleft”><?php next_posts_link(‘« Older Entries’) ?></div>
<div class=”alignright”><a href=http://www.yourlink.com/archives/>Site Archives »</a></div>
</div>
<?php } ?>
You can read a full description here to get a better understanding.





Recent Comments