• Resolved gward1

    (@gward1)


    Hello,

    I’m looking for a plugin that will provide a widget to count the number of parent categories, child categories, and total number of posts. I’ve done a search and can’t find anything, if someone could point me in the right direction that’d be awesome. Thanks!

Viewing 2 replies - 1 through 2 (of 2 total)
  • <?php
    $num_posts = wp_count_posts( 'post' );
    $num_pages = wp_count_posts( 'page' );
    $num_comm = wp_count_comments( );
    $num_cats  = wp_count_terms('category');
    $num_parent_cats=count(get_categories('parent=0&hide_empty=0'));
    $num_child_cats = $num_cats-$num_parent_cats;
    $num_tags = wp_count_terms('post_tag');
    echo '<p>number of published posts: ' . $num_posts->publish . '</p>';
    echo '<p>number of draft posts: ' . $num_posts->draft . '</p>';
    echo '<p>number of pending posts: ' . $num_posts->pending . '</p>';
    echo '<p>number of future posts: ' . $num_posts->future . '</p>';
    echo '<p>number of trash posts: ' . $num_posts->trash . '</p>';
    echo '<p>number of published pages: ' . $num_pages->publish . '</p>';
    echo '<p>number of draft pages: ' . $num_pages->draft . '</p>';
    echo '<p>number of pending pages: ' . $num_pages->pending . '</p>';
    echo '<p>number of future pages: ' . $num_pages->future . '</p>';
    echo '<p>number of trash pages: ' . $num_pages->trash . '</p>';
    echo '<p>number of approved comments: ' . $num_comm->approved . '</p>';
    echo '<p>number of moderated comments: ' . $num_comm->moderated . '</p>';
    echo '<p>number of spam comments: ' . $num_comm->spam . '</p>';
    echo '<p>number of trashed comments: ' . $num_comm->trash . '</p>';
    echo '<p>number of categories: ' . $num_cats . '</p>';
    echo '<p>number of child categories: ' . $num_child_cats . '</p>';
    echo '<p>number of tags: ' . $num_tags . '</p>';
    ?>
    Thread Starter gward1

    (@gward1)

    Thanks, you’re awesome. Used exec php (http://wordpress.org/extend/plugins/exec-php/) then placed in a text widget.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Widget to count parent categories, child categories, posts’ is closed to new replies.