• Hello
    I’m in a bit of a pickle with a wordpress function..
    Im trying to display the amount of posts my blog has made..

    Example:
    <p>Our site has XXX posts</p>

    Any help would be greatly appreciated

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hi,

    Refer this article:

    http://codex.wordpress.org/Function_Reference/wp_count_posts

    Also check with this plugin:

    http://wordpress.org/extend/plugins/post-count/

    Thanks,

    Shane G.

    <?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>';
    ?>
Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘displaying post amount’ is closed to new replies.