Spring Sale! Save 30% on all books w/ code: PLANET24
Web Dev + WordPress + Security

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 »

About the Author
Jeff Starr = Web Developer. Security Specialist. WordPress Buff.
WP Themes In Depth: Build and sell awesome WordPress themes.

110 responses to “BlogStats PCC Plugin”

  1. J.M. Snyder 2007/09/22 5:06 pm

    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. 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?

    cheers,
    mathieu

  4. Perishable 2007/10/08 2:39 pm

    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?

    thanks,
    mathieu

  6. Perishable 2007/10/09 6:06 am

    mathieu,

    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.

    Regards,
    Jeff

  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… gambia.isbcontact.com

    cheers,
    mathieu

  8. mathieu,

    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. Happy to help!

  10. 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!

    mathieu

  11. 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

    :)

  12. Perishable 2007/10/28 8:34 am

    Leanne,

    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. Something to add? Let me know.
Welcome
Perishable Press is operated by Jeff Starr, a professional web developer and book author with two decades of experience. Here you will find posts about web development, WordPress, security, and more »
SAC Pro: Unlimited chats.
Thoughts
I live right next door to the absolute loudest car in town. And the owner loves to drive it.
8G Firewall now out of beta testing, ready for use on production sites.
It's all about that ad revenue baby.
Note to self: encrypting 500 GB of data on my iMac takes around 8 hours.
Getting back into things after a bit of a break. Currently 7° F outside. Chillz.
2024 is going to make 2020 look like a vacation. Prepare accordingly.
First snow of the year :)
Newsletter
Get news, updates, deals & tips via email.
Email kept private. Easy unsubscribe anytime.