WordPress.org

Ready to get started?Download WordPress

Forums

How to find the number of posts in a category (6 posts)

  1. Dalton
    Member
    Posted 8 years ago #

    I'd like to add a line of text to the archive page when people browse by category that says "There are X posts in this category". How do I find out how many posts are in a category?

    I've looked through the forums, I've looked through the codex, to no avail. I know it's possible because the number shows up on the category admin panel, but I can't figure out how it's done.

  2. ladydelaluna
    Member
    Posted 8 years ago #

    there's a way to do it in the category links list (in the sidebar, or wherever you happen to have your categories listed out)... so that after the category title, a number in parenthesis shows up saying how many posts...

    http://codex.wordpress.org/Template_Tags/wp_list_cats

    you'd use something like this (but read the above link to determine exactly what you want):

    <ul>
    <?php wp_list_cats('sort_column=name&optioncount=1'); ?>
    </ul>

    It's the optioncount=1 that will give you the number...

  3. Dalton
    Member
    Posted 8 years ago #

    Right, but displaying the entire list of categories unfortunately isn't an option in this case. I was kinda hoping there was some sort of hidden option for single_cat_title(), but that seems unlikely.

    How do they do it in the category admin section?

  4. Dalton
    Member
    Posted 8 years ago #

    nudge?

  5. Jauhari
    Member
    Posted 8 years ago #

    I want display count only on child but on Main categories the count will gone. How to do that?

  6. hip
    Member
    Posted 8 years ago #

    Hi daltonrooney,

    I've just posted what may be a solution to your q.

    http://wordpress.org/support/topic/12805?replies=5#post-424730

    Have a good day,
    hip

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags