Support » Fixing WordPress » Variable to determine last page

  • I’ve figured out pagination, and inserted the code into my index.php. All is well with that, and I’ve also been able to make sure that my span tags surrounding the previous and next links don’t show up when they’re not needed. However, I’d like to know if there is a variable that tells you how many pages there are, or a variable that tells you that you’re on the last page, as right now comparing count($posts) with $posts_per_page. Here’s the code, wondering if there’s a better way?

    <div class="previous_next_links">
    <?php if ($paged): ?>
    <span class="prev_posts_link"><?php previous_posts_link() ?></span>
    <?php endif; ?>
    <?php if (count($posts) == $posts_per_page): ?>
    <span class="next_posts_links"><?php next_posts_link() ?></span>
    <?php endif; ?>
    </div> <!-- previous_next_links -->

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Variable to determine last page’ is closed to new replies.