How can I properly tell if there are “more” in category?
-
I started my own set of templates from scratch. At the moment, the code I’m using to tell whether to display “previous / next” on my category page is pretty hacky (see below); I am counting the number of posts displayed on the page, and if it equals 10 (the max number that can be displayed) then I display the previous/next links. However, of course, if a category has exactly 10 posts (or total mod 10 == 0), then the next link is invalid, since there are no more posts to display. How can I ask wordpress if there are indeed more posts to display after this set?
<?php $numPosts = 0; ?>
<?php foreach ($posts as $post) : start_wp(); ?>
<?php require('post.php'); ?>
<?php if($id > 0) { add_count($id);} ?>
<?php $numPosts += 1; ?>
<?php endforeach; ?>
<?php if ($numPosts == 10) : ?>
<?php posts_nav_link_hack("", "Previous", "Next") ?>
<?php endif; ?>
- The topic ‘How can I properly tell if there are “more” in category?’ is closed to new replies.