• 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; ?>

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter Reuben

    (@reuben)

    That’s what I’m using tho; my hack function is just to add a css class to the links. It still shows up with “next” even if there aren’t posts on the next page. Any other ideas what could be wrong here?

    I am not sure I understand the whole issue and your code complication. WP does it automatically: using the proper template tag it will display –
    Previous Posts
    or Previous Posts + Next Posts
    or Next Posts
    depending on wich “paged” view you are on. The “counting” is done based on your settings in Options > Reading: # of posts shown.

    So, why are you re-inventing the wheel?

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How can I properly tell if there are “more” in category?’ is closed to new replies.