BlogStats PCC Plugin
Posted on August 28, 2006 in WordPress by Jeff Starr
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, and completely free.
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
- Unzip blogstats-pcc.zip and copy blogstats-pcc.php to your plugins directory.
- Upload and activate via WordPress plugin admin panel.
- Add any of the following calls to wherever you would like the information displayed:
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(); } ?>
Download the Latest Version
Download BlogStats PCC [ version 2.3.1 | ~3KB | .zip | 893 downloads ]
Previous/Alternate versions of BlogStats PCC
- BlogStats PCC Version 2.3.0a [ 2526 downloads ]
- BlogStats PCC Version 2.3.0a [ 974 downloads ] ( adapted for WordPress MU )
- BlogStats PCC Version 2.0.0 [ 2212 downloads ]
- BlogStats PCC Version 2.0.0 [ 1070 downloads ] ( en Francais )
- BlogStats PCC Version 1.9.9 [ 1866 downloads ]
- BlogStats PCC Version 1.9.9 [ 1082 downloads ] ( en Espanol )
- BlogStats PCC Version 1.7.9 [ 1359 downloads ]
- BlogStats PCC Version 1.7.7 [ 1351 downloads ]
- BlogStats PCC Version 1.1.1 [ 1233 downloads ]
- BlogStats PCC Version 0.9.9 [ 1206 downloads ]
Related articles
- New Version of BlogStats PCC for WordPress 2.3
- Display the Total Number of WordPress Posts, Comments, and Categories
- Perishable Press WordPress Plugins
- Category LiveBookmarks Plugin
- Critical Review of Dyasonhat’s Premium Smart Sort WordPress Plugin
- AddMySite Plugin for WordPress
- WordPress Plugin: Authenticate Lite
wow
i like the design of the comments section.
looks cool.
can i use it in my blog ? how can i edit it in my blog ?
and thanks for the plugin.
Nice, works like a charm, thank you :)
It is my pleasure — thank you both for the positive feedback!
How can I let it work in my blog ?
I have actived it in my “Plugin” panel,how to display it in my index page ? Thank you !
airedge,
Open the plugin with a text editor and follow the "Installation and Use" instructions. Simply include any of the provided
phptags anywhere within thebodyof your pages. That’s all there is to it!Thank you very much perishable!!!
I have made it !
Thank you for this simple but sweet little plugin!
Much appreciated!
“Long live open-source”
thanks. It’s really easy. :)
Thank you all for the positive feedback — your comments are greatly appreciated and inspire us to continue contributing code and content to the open-source WordPress community. Cheers!
Maybe I don’t get it. I am new to PHP. I am wondering if this is a plugin that I can use only on the ADMIN page and if not, how do I get it to be on one of the pages that I have named STATS?
bulletz,
To add BlogStats PCC functionality to your Admin Dashboard, open the
wp-admin/index.phpfile and locate this code:<div id="zeitgeist">
<h2><?php _e('Latest Activity'); ?></h2>
Immediately after that code, add the following:
<h3><?php _e('Statistical Overview'); ?></h3>
<?php fullstats(); ?>
Upload the
wp-admin/index.phpfile to your server and you should be good to go.Now, to add the same statistical information to the blog itself, simply add this code to the location at which you would like to display your blog’s statistics:
<?php fullstats(); ?>
Finally, please keep in mind that if you open the BlogStats PCC file itself (say, with a simple text editor), you will find there are many ways to customize your statistics.
Cheers!
I was able to put the snippet of code into the wp-admin/index.php page to get stats to appear there, but i still don’t get how to make the stats appear on the blog itself. What file specifically am I looking for if I want to get the stats on the main page of the blog?
Thank!
Just wondering:
Is there any way for the plugin to avoid showing comments caught with Akismet? All new spam-comments show on up on my ‘recent comments’-display - before I even get as far as deleting them.
Great plugin by the way :-)
Peter T,
BlogStats PCC works anywhere within the <body> of your blog documents. If you would like the plugin to show stats from your blog’s sidebar, for example, you would open the sidebar.php file located within the "/wp-content/themes/your-theme(whatever it is)/> directory, and add this snippet of code:
<?php fullstats(); ?>
Otherwise, within the same directory (your theme directory), open the index.php file and place the code in an appropriate location.
I hope that helps. If you would like more help, please contact me. I would be more than happy to help you get BlogStats PCC working on your blog.
Brom,
You are absolutely correct — only comments that have been approved should display in the "most recent comments" stats. I have made the required modifications and released a new version (1.7.9) of the plugin, which may be downloaded via the post link above. Thank you for the excellent suggestion!
Incredible, my good man - thanks for the quick update :-D
Is there any way to donate? Your plugin deserves it!
Cheers,
Brom
great plug-in. just installed it!
Thanks so much for the great plugin. Is there any way I can add something to the script to also call the “page” count? Right now it only counts posts but I would like to also show how many “page”s I have.
Thanks so much!
John,
Including a "Page Count" stat is an excellent idea — I will look into it and report back within a few days. Stay tuned..
danfef,
Thanks for the comment — glad you enjoy it!
John,
Thanks to your feedback, BlogStats PCC now displays the total number of individual static pages. Download the new version (1.9.9) via the main download link above. Thanks for the idea!
Hi..I cannot locate this code anywhere within my wp-admin/index.php:
I’ve been to my server and located the wp-admin/index.php..but that code is not there. Am I supposed to access that file through my Wordpress computer folder..if so also can’t find the file itself. I have a wp/options/index/phpfile..but there’s nothing in it.
Help..am probably missing something very simple so forgive me.
This is what’s in my server public_html / wp-admin/indexphp file:
[ - edited - ]
Thanks for the help.
mary,
I assume you are trying to insert the stats function into your admin dashboard as per comment
#12, above. If that is indeed the case, then openwp-admin/index.php(either online or offline) and look again for this code (you could even do a find/search for it):<div id="zeitgeist"><h2><?php _e('Latest Activity'); ?></h2>This code is identical in your particular version of WordPress (2.0.1) and should definitely be present (near the top of the document) in order for your site admin to function properly.
Try logging in to your admin section and see if the dashboard is looking up to snuff. If it feels right, then the specified code should be in the file location indicated. If you are certain that the file lacks such code, you could always unzip a fresh copy and restore it.
Note: Most of the code you posted in your previous comment was "eaten" by WordPress. From the shreds of php that remain, it appears that you copied only a portion of the entire document. Try checking again, only this time please do not post the code. Thanks;)
A very good and clean plug-in.
I have translated your plug-in to spanish (Spain). If you’re interested, send me an email.
Greetings!
Thank you SO much for making this so simple and customizeable. Very appreciated.
Thanks for the suggestion…I’ll try a clean install and get back to you..sory about posting all that code. Shoulda known better.
Hello,
Great plugin.
I would like to use this in WordpressMU.
And, in any case, I would like to get total posts in each category and list like
Category1 - 45
Category2 - 30
and be able to control some stuff like which categorys info to get and display only the post count.
Is that doable? Thank you.
Abhimanyu Chirimar,
Let me look into it.. I have not yet worked with WPMU, so that may prove interesting. The individual category stats should not be difficult, however I am a little confused about the second part of your request. Would you mind clarifying a bit?
What is the best way to add this to it’s own “stats” page? My photoblog theme doesn’t use a sidebar. I’ve tried creating a standalone stats.php with the fullstats in it, but get a php error.
Matt,
I just checked your stats page — it looks like everything is working now..? If not, let me know — otherwise, congrats!
Could you please feature documentation and instructions on usage and Plugin template tag options on your site instead of just within the Plugin or in the comments here? It would really help people understand how this works and how to make it do what they want. Thanks.
Lorelle,
Thank you for pointing this out. We had posted installation and usage documentation for our other plugins, but somehow forgot to include the information for BlogStats PCC. We now have fixed this oversight and have posted complete documentation for BlogStats PCC. We apologize for any frustration caused by our apparent lack of concern. Thank you for helping to improve the quality of our humble website.
Cheers,
Jeff
Works great! I have one question though, is there any way to change the format of the date? Thanks!
Norm,
Customizing the date format for the most recent blog update was previously very tedious and not very user friendly. So, we have added a new function to the BlogStats PCC plugin that will simplify the process.
First, download and install the new version (2.0.0). Then use this function instead of the previous one:
<?php if (function_exists('recstats')) { recstats(); } ?>This function should output the last-update information according to the default date and time settings of your blog (under Options in the WP Admin). If that date works for you, then great — you are good to go. Otherwise, scroll through the file and locate the function itself. There, you will find comments concerning customization of the date and time format.
Regards,
Jeff
Thanks very much, appreciate the amazingly fast response! Nice, simple & clean plugin.
It is our pleasure to help! We are glad that BlogStats PCC is working well for you. Thank you for the kind remarks. Cheers!
Hi, nice work for this pluggin! :) But i got a little problem… I want to ‘create a page’ from the dashboard that will show the stats on it. But the problem is that it doesnt process the php tag code on the textarea to write the page. I must put the tags on the sidebar for them to work..
Sorry for my english :)
thx and ciao!
daive,
After you have created a page, open your WP Admin and click on "Presentation". Then, under Presentation, click on "Theme Editor". Once inside the Theme Editor, locate your new page in the list of files on the right. Finally, add the BlogStats PCC function call(s) to the location of your choice. Don’t forget to click the "Update File" button to save your changes. After that, check your page, everything should be working fine.
Let us know how it goes!
Thx, it was my mistake.. It work fine :)
Mmmh sorry but my pages doesnt appear on my files list to edit on the theme editor, any ideas?
You need to create a page before it will appear in the list. In this case, creating a page requires a custom page template. Only pages with custom templates will appear in the theme editor. Check out http://codex.wordpress.org/Pages (about halfway down on the page: "Page Templates") for more information about creating custom page templates. Once you have the custom page template in place, the steps outlined in my previous comment should apply.
Good luck!
Counting posts in categories is fine. But I have posts that can belong to several categories. I have a small routine (using an array) which selects posts that are - for example - both in category A and category B. What I would like is to display the number of posts that are displayed by this selection. May your plugin be adapted to this? Thanks for your wisdom!
Martin,
That definitely sounds possible..
Email the code you are using along with any pertinent information and we will look into it..
Jeff
Why DOESN’T it work? I did everything like’s written and it doesn’t. What’s up?
Did you get it working? I checked your site and it appears to be displaying statistics in the sidebar..
‘sup..
It’s different statistics. But nevermind. I decided to use different plugin.
Hello,
I have a question. The “guests” (unregistered users”) are the number of visitors at a given moment? In real time?
Thanks! Great plug in.
The number of "Guests" reflects the number of users that have registered as a subscriber/member for your blog, not the number of visitors currently visiting your site.
great little plugin. i have a 2 questions i want to ask before i go screwing up the php file.
1. changing the number of recent posts and comments listed
2. You had said that “guests” is actually users who have registered. how do i change “guests” to something that would reflect that, like “registered Users”?
billy,
not sure if i am understanding the first question.. the number of posts/comments is generated from database statistics. changing the number of either requires altering the actual number of posts/comments in the database itself (e.g., by adding/deleting posts).
the second question is easy. open the file and go to line #114. change the word "guests" to whatever you prefer. no additional editing should be necessary.
Hello,
thanks for this great plugin Perishable ;)
I translate this in French: [Edit: getting 404 for original page link — see download section of the article above for the translated version]
It is also available on the official French Wordpress site.
Arkan,
Very nice! Thank you for your help. The translation is excellent. Keep up the good work!
Regards,
Jeff
Finally I have found a great plugin to show a the stats about my blog - thank you.
I like the way I can list posts and pages separately, but it seems to miss out a whole load of sub pages. Any ideas??
Yes, open the plugin file, find the function called
function pagestats(), and replace this line:$numpages = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->posts WHERE post_status = 'static'");with this one:
$numpages = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->posts WHERE (post_status = 'static') AND (post_parent >= '0')");That should do the trick. Let us know how it goes..
Thanks for the amended code, unfortunately no change. Still showing 6 pages.
If I change it to
(post_parent >= '1')it then says 2 pages.At the moment your plugin is reporting:
59 posts and 6 pages in 11 categories with 56 comments
While the WP Dashboard reports:
There are currently 43 posts and 56 comments, contained within 11 categories.
Probably should have said I am using WP2.1
Thanks for your help.
I don’t have WordPress 2.1 running for this site (yet), but I may have an opportunity later tonight or tomorrow to investigate the situation on a different domain. It should be just a matter of culling the desired page data from the correct database tables, which indeed may have been changed in WP2.1. I’ll see what I can do.. stay tuned..
Exellent, it works very well. Very usefull tool ;)
i just installed this plugin on my blog and i love it! thank you!
Excellent, Manele — I love to hear positive feedback! Thanks for the comment!
Hi,
Great plug-in! However, I’m using the “poststats” function and it’s returning the number of all my posts AND my pages.
Your plug-in stats: 57 posts, 0 pages
WordPress dashboard: 50 posts
I have 1 post that’s marked private and 1 page marked private, for a total of 51 posts and 8 pages.
Any clue why this may be happening?
Thanks in advance!
J.M. Snyder
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!
Thanks for sharing that solution, J.M. Snyder ;) I am glad that you find the plugin useful!
— Cheers!
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
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 ;)
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
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
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
mathieu,
Aha! It turns out that the WordPress
wp_poststable 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 ;)
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
Happy to help!
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:)
Leanne,
Thanks for the heads up.. I am looking into it now. I will post again later today or tomorrow.
:)
New version of BlogStats PCC now available! Check out this post to read the announcement, or simply scroll up to the download portion of this page to grab yourself a fresh copy. The new version is numbered
2.3.0a, and is compatible with all versions of WordPress (1.5 - 2.3).Hi,
I just downloaded your plugin … nice work!!
However, I discovered a bug:
poststats()counts not only posts but pages too. Simply addANDpost_type='post'to the query. I haven’t tested the other functions.Furthermore I would prefer
poststatsto return the number only… thus I may use it more flexible.Again, thanks a lot for the great work!!
Cheers,
jj
JJ,
Yes, thanks for the feedback! A similar issue was resolved awhile ago for the “latest-post” function (
recpost()) using the same trick: addingANDpost_type='post'to the database query (see comments #63-70 for the full story). There are even alternate versions of functions buried in the latest release of the plugin (v0.88) that were used for testing (look forrecpageless()andrec_pageless()). In any case, we appreciate the heads up and thank you for helping to improve the BlogStats PCC plugin ;)Regards,
Jeff
Just downloaded the plugin and installed it on one of my personal blogs, and it’s fantastic! Thanks so much for this. =)
i have tested it ! it’s great ! thank you man !
thank you for the simple and easy to use plugin!
You are most welcome, tnchick — thanks for the feedback :)
Hi,
I am using this plugin to display the entire set.
I copied the code above you mentioned and pasted it on my static page for sitestats in the code section of the edit page.
However, no stats is displayed.
I am using wp 2.2.2
Thanks for any help
Hostorials,
When you say, “code section of the edit page,” are you referring to the WordPress Admin panel found at Manage » Pages » Edit Page? If so, that is the problem — unless you have a plugin that enables WordPress to process PHP in post content, placing the function call in this way will not work. You will need to create a template page for stats and then edit it directly with the same code.
Regards,
Jeff
Jeff…
Thank you. It’s working now.
Excellent — glad to hear you got it working :)
i’m tested it and i’m glad that worked for me…
thanks again
My pleasure :)
Statistics for number of tags? I’m missing that one, or am I overlooking something?
jack, you are right — I definitely need to add statistics for “total number of tags”.. As mentioned in the email, I will look into adding this feature to the BlogStats plugin just as soon as time allows. Hopefully, within the next couple of days!
Hello Perishable,
Any news on the number of tags option?
Also I found that there is a mismatch between the amount of pages and posts total.
WordPress says that there are 992 posts and 9 pages, while Blogstats says there are 1001 posts, using the poststats() function and the latest version of your plugin.
Any idea how or why this is?
Hi jack, if you are referring to Blogstats functionality on WP 2.5, I haven’t yet tested it. I am working on it, but with my current workload it may be awhile longer before I can get there. As for the issue at hand, it seems that the
poststats()function is combining the total number of pages and posts in WP 2.5? If so, this information will be useful in determining the cause of the discrepancy. Without diving into it right now, I would guess that WP 2.5 changed another parameter in the database. I will look into it as soon as possible..So is it working on 2.5.1 properly now???
Did any one test it???
sam, although I have yet to test it myself, BlogStats should work fine with WordPress 2.5+. The only exception (to my knowledge) is that the total post count combines the total number of posts with the total number of pages (see comment #88). If you can live with that until I find time to update the plugin, everything should work fine.
Good Job for BlogStats PCC Plugin !!
If you want to add a Tags number counter at this plugin, add this on your plugin page :
// total number of tagsfunction tagstats() {global $wpdb;global $numtags;$wp_test = get_bloginfo ('version');if($wp_test >= 2.3) {$numtags = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->term_taxonomy WHERE taxonomy = 'post_tag'");}if (0 < $numtags) $numtags = number_format($numtags);echo $numtags . ' Tags';}and after, add this on your template :
<?php if (function_exists('tagstats')) { tagstats(); } ?>Look at the bottom of rssparadise for exemple !!
@Godparadise: that is great! I will definitely be implementing that functionality in the next version of Blogstats PCC! Thank you for helping improve the Blogstats plugin by sharing this with us! :)
Cheers,
Jeff
Great plugin! Just wondering though if there’s a bug? When displaying the number of posts, it looks like it includes posts and pages. Is there a way to only have it display the number of posts? Thanks!
@Josh: Yes, you are correct; until I find time for an update, check this comment (and the subsequent comment) for an easy fix.
Ah, I should have read a bit more! Thanks for that, it was an easy fix!
When displaying the last update, it goes by the publish date. However, if you published something for a future date, it won’t go by that date when that date arrives, it still goes by the date you initially published (scheduled) it. Any workaround for this?
Thanks!
@Josh: That will take some looking into.. Assuming the time records are distinguishable and accessible, it should be possible. I’ll see what I can do!
Is there a way to exclude a specific category from the total posts count? I tried using
AND post_category != '1'but it didn’t work.Hi, great plugin! Do you have a demo of it on a page somewhere?
Thanks!
Trinifieds
@Trinidad: Yep: http://perishablepress.com/press/dungeon/
Scroll down to the second subheading to see the plugin in action.
Thanks! Looks wonderful..
I have problem displaying categories…
..it shows empty with function blogstats()
..and wordpress 2.9.2
..but in other functions like fullstats() and catstats() it works :)
Hi aimar,
I fixed this and updated the plugin. You may download the new version (2.3.1) using the official download link.
i have wordpress 3.0 and this plug in says i have 35 published post when i only have 18
Hi antonio, I haven’t tested the plugin on recent versions of WordPress, including 3.0, so it’s probably incompatible (at least for that aspect of its functionality). I am thinking that the over-count is due to post drafts, which will need excluded during the next plugin update.
Hello Jeff, (sorry for my english) i exclude one or more categories to “function catstats” ? it’s possibile ?
Hey Fask, send me an email and I’ll try to help. Thanks.
in the next version you can also integrate this function written by me:
Display Recently Updated Posts for category:
http://pastebin.com/CQ3DL7sg
How can I display the total comments from a Wordpress blog site on a web page?
example : Blog Site Comments: 32
I would like to have a script to read the URL:
monessen1963.wordpress.com/feed,then display the results on a web page.
I know a little javascript, but not familiar with php.