WordPress.org

Ready to get started?Download WordPress

Forums

wp_count_posts - specific category (3 posts)

  1. Tom(dB)
    Member
    Posted 6 years ago #

    I have got a full post count using the wp_count_posts method (see below). But I want to display post count for a specific category. Does wp_count_posts support this yet?

    wp_count_posts in Codex

    <?php
    $count_posts = wp_count_posts();
    $published_posts = $count_posts->publish;
    echo 'Total published items: '.$published_posts;
    ?>

    edit: version 2.5.1 used.

  2. Ivovic
    Member
    Posted 6 years ago #

    What you want is the 'count' field in wp_term_taxonomy, which is the number of times a particular term (aka category) has been used.

    See this thread: http://wordpress.org/support/topic/136905

    Perhaps it won't bother you too much that your drafts are also counted, as they shouldn't be drafts forever.

  3. edebiyat01
    Member
    Posted 6 years ago #

    Thanks Ivovic.

Topic Closed

This topic has been closed to new replies.

About this Topic