27
Oct 09
If you have a popular WordPress blog with good number of comments everyday you might want to display the total number of comments published on your WordPress blog since your blog launch.
Here`s how to do it in three easy steps:
Go to wp-content\themes\youtheme folder and open functions.php in a text editor (notepad is good)
Paste the following code somewhere in the file, at the end, right before the php code ends is ok, so right before this tag “?>”, So it will look like this:
1 2 3 4 5 | function comment_count() { global $wpdb; $count = "SELECT COUNT(*) FROM $wpdb->comments WHERE comment_approved = '1' AND comment_type != 'pingback' OR comment_type != 'trackback'"; echo number_format($wpdb->get_var($count)); } |
To use it, just put <?php comment_count();?> wherever you want to display the total number of comments (e.g. the sidebar.)
Example of usage:
There area total of <?php comment_count();?> comments for this blog.
Result:
There area total of 1564 comments for this blog.
1 Trackbacks/Pingbacks
- Pingback: Visualizzare il numero complessivo dei commenti del nostro blog Wordpress // Tr3ndy.com on October 28, 2009



works for me
emm. 10x for post
good going
+1