Latest TweetsDifference between mod_alias and mod_rewrite…
Perishable Press

BlogStats PCC Plugin

[ BlogStats PCC ] Announcing the BlogStats PCC plugin for WordPress! BlogStats PCC is the easy way to display the total number of posts, comments, categories, as well as several other great statistics for your WordPress-powered website. With BlogStats PCC, you display only the information you want, where you want — inside or outside of the WordPress loop. Completely customizable, BlogStats PCC will display any combination of statistics you choose. This plugin is highly flexible, simple to use, open source, and completely free.

Update: BlogStats PCC has been rebuilt with all new features and options. Check out Simple Blog Stats for all the action! </update>

BlogStats PCC update

New version of BlogStats PCC now available! The new version now provides all of these great site statistics:

  • Total number of posts
  • Total number of comments
  • Total number of categories
  • Total number of members
  • Total number of guests
  • Total number of pages
  • Date of most recent update
  • Most recent commentator
  • Most recent post

Display any or all of the provided site statistics — customize your own set to provide only the statistics you want!

Installation and Usage

  1. Copy blogstats-pcc.php to /wp-content/plugins/
  2. Upload and activate via WordPress plugin admin panel
  3. Use the following tags to display your stats anywhere:
Display the entire set of statistics in a nice list format:
<?php if (function_exists('fullstats')) { fullstats(); } ?>

Display the total number of posts, comments, and categories:
<?php if (function_exists('blogstats')) { blogstats(); } ?>

Display the total number of posts:
<?php if (function_exists('poststats')) { poststats(); } ?>

Display the total number of comments:
<?php if (function_exists('commstats')) { commstats(); } ?>

Display the total number of categories:
<?php if (function_exists('catstats')) { catstats(); } ?>

Display the total number of registered users:
<?php if (function_exists('regusers')) { regusers(); } ?>

Display the total number of unregistered users:
<?php if (function_exists('userstats')) { userstats(); } ?>

Display the total number of individual, static pages:
<?php if (function_exists('pagestats')) { pagestats(); } ?>

Display the date of the most recent post modification:
<?php if (function_exists('modstats')) { modstats(); } ?>

Display a link to the most recently published blog post:
<?php if (function_exists('recpost')) { recpost(); } ?>

Display the name of the most recent commentator as a link:
<?php if (function_exists('reccomm')) { reccomm(); } ?>

Display the date of the last update in your blog's default date format:
<?php if (function_exists('recstats')) { recstats(); } ?>
Check it out: Simple Blog Stats »

Jeff Starr
About the Author Jeff Starr = Creative thinker. Passionate about free and open Web.
110 responses
  1. NM, I fixed it. I changed the line:

    $numposts = $wpdb->get_var(“SELECT COUNT(*) FROM $wpdb->posts WHERE post_status = ‘publish'”);

    to read:

    $numposts = $wpdb->get_var(“SELECT COUNT(*) FROM $wpdb->posts WHERE post_status = ‘publish’ AND post_type = ‘post'”);

    And that cleared things up. Thanks again for this great plug-in!

  2. Jeff Starr

    Thanks for sharing that solution, J.M. Snyder ;) I am glad that you find the plugin useful!
    — Cheers!

  3. hello!

    first of all, great plugin. Everything works fine right from the start and im loving it! I would like to change that the most recent post stat only shows posts, and not pages. At the moment, it says that the most recent post is “Archives”, which is a page I just created. Any ideas?


  4. Jeff Starr

    Hi mathieu,

    Excluding pages from the “Recent Post” function is straightforward. Open the plugin file, find the function called recpost(), and replace this line:

    $lastpost = "SELECT ID, post_title, post_date FROM $wpdb->posts WHERE post_status = 'publish' ORDER BY post_date DESC LIMIT 1";

    ..with this one:

    $lastpost = "SELECT ID, post_title, post_date FROM $wpdb->posts WHERE post_status <> 'static' AND post_status = 'publish' ORDER BY post_date DESC LIMIT 1";

    ..and that should do it. Let me know how it goes ;)

  5. Hello!

    thanks for the fast reply! I did the changes you recommended but still it shows the latest page as latest post. Could this be due to the theme Im using (Hemingway4u)? Any other ideas?


  6. Jeff Starr


    It is unlikely (though possible) that the theme is causing the issue. A quick way to test that would be to activate one of the default WP themes and check again. By the way, which version of WordPress are you using? This may have something to do with WordPress 2.3 or even 2.2, for that matter.


  7. Hmm.. again, thanks for the quick reply! I am running 2.2.1, have tried to change themes but that did not affect the archives… Could it be that i need to change any more/other code? It doesnt really matter that much in the end, because as soon as I add a new post it will change, but it might help me sort out a problem I am having with extended Live Archives which shows pages in the archive where I would only like to have posts…


  8. Jeff Starr


    Aha! It turns out that the WordPress wp_posts table structure is slightly different in version 2.2. Try the following code, via the same function as before:

    $lastpost = "SELECT ID, post_title, post_date FROM $wpdb->posts WHERE post_status = 'publish' AND post_type = 'post' ORDER BY post_date DESC LIMIT 1";

    ..and that should do it! Let me know how it goes ;)

  9. ok, that did the trick indeed! thanks for your help! Things are running smoothly now, although I think ill need to change it back to the initial piece of code you gave me at first! thanks again!


  10. Just an FYI – your plugin broke when I just upgraded to 2.3.1 – the error:

    wp_categories' doesn't exist]
    SELECT COUNT(*) FROM wp_categories


  11. Jeff Starr


    Thanks for the heads up.. I am looking into it now. I will post again later today or tomorrow.


[ Comments are closed for this post ]