Forums

[resolved] How to display total number of posts found/fetched (4 posts)

  1. 27shutterclicks
    Member
    Posted 1 year ago #

    I have the theme setup so that when a category is selected (by clicking on the default sidebar categories widget for example, or the archive page), the posts in that category get displayed 9 at a time... if there are more than 9, I get the pagination links.

    I would like to know how to display the total number of posts in the category/archive/search, at the very top of the posts. For example: "Found 23 posts..."

    I've tried echo ($wp_query->post_count), but this can only show a max number of 9.

    Any suggestions?

    Thanks.

  2. 27shutterclicks
    Member
    Posted 1 year ago #

    I've done some more digging and finally found the answer, as per this other support forum post: Get count position in total post count.

    The simple answer was to use echo $wp_query->found_posts ;

    Marking as resolved.

  3. 27shutterclicks
    Member
    Posted 1 year ago #

    Is there any codex page that details all the variables available in $wp_query?

    For example, I was unable to find anything on "found_posts" in the WP Query Reference Page.

  4. vincentlopy
    Member
    Posted 1 year ago #

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags