Support » Themes and Templates » Pagination

  • Resolved ckruse

    (@ckruse)


    I am having trouble with pagination. First of all, I know there are several plugins out there, but I have a custom display, so I do not want to use one.

    If I use any nice permalink structure, my pagination does not work. My home page displays all of my posts and paginates them. This is the code I have at the top of my home page just before the loop.

    if($paged == 0) { $paged = 1; }
    query_posts(‘paged=’ . $paged . ‘&showposts=1&cat=-1’);

    Then at the bottom of the page I have:

    <?php next_posts_link( ‘<img src=”myPrevImage” />’); ?>
    <span><?php echo $paged . ” OF ” . $max_pages; ?></span>
    <?php next_posts_link( ‘<img src=”myNextImage” />’); ?>

    If you notice, I am trying to display page 1 of 10 for example. How do I calculate or get the max number of pages?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Michael

    (@alchymyth)

    Forum Moderator

    the number of published posts is (used before the loop):

    <?php $count_posts = wp_count_posts();
    $published_posts = $count_posts->publish; ?>

    with ‘showposts=1’ this is also the max number of pages.

    Ok, well how do you use that with a custom query. On my home page I have the custom query which does not show “Uncategorized” posts and limit to 3 posts.

    I wrote a custom query to get all posts. But how could I use this. For example, on an archive page.

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