WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Pagination (3 posts)

  1. ckruse
    Member
    Posted 4 years ago #

    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?

  2. alchymyth
    The Sweeper & Moderator
    Posted 4 years ago #

    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.

  3. ckruse
    Member
    Posted 4 years ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Topic