Checking if there are next posts
-
Ok, so I’m working on a theme and I want it to check if there are next posts to display. Something along these lines:
<?php if (next_posts_link() || previous_posts_link()) { ?>
<div class="alignleft"><?php next_posts_link('« Previous Entries') ?></div>
<div class="alignright"><?php previous_posts_link('Next Entries »') ?></div>
<?php } ?>Of course, this doesn’t work, because if next_posts_link does have something, it echoes it instead of returns it, and the whole thing stops.
So, there is no get_previous_posts_link or anything like that, so what do I do? I can’t just have it display nothing in an empty div, because there are other elements I want to wrap these links in, but only if they exist. Understand what I mean? How can I check if there are other pages without echoing the page links?
Thanks for any help
- The topic ‘Checking if there are next posts’ is closed to new replies.