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

  1. Pingback: Visualizzare il numero complessivo dei commenti del nostro blog Wordpress // Tr3ndy.com on October 28, 2009

4 Comments

  1. works for me

  2. imitrex on December 1st, 2009 at 8:14 pm
  3. emm. 10x for post :)

  4. ererraky on December 11th, 2009 at 9:59 am
  5. good going

  6. tamsulosin on December 14th, 2009 at 12:48 pm
  7. +1

  8. flomax on December 14th, 2009 at 5:20 pm

Leave a comment

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">