Display the Total Number of Comments on Your WordPress Blog
by Hiroshi on November 16th, 2008
sponsored links
In this tutorial we will learn how to show total number of comments at your blog using the $wpdb object. Use the following code where you want to display total number of comments at your blog.
<?php $numcomms = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->comments WHERE comment_approved = '1'"); if (0 < $numcomms) $numcomms = number_format($numcomms); ?> |
Here $numcomms variable contains the total number of comments posted on your WordPress blog. To display this number, simply do something like:
<?php echo "There's ".$numcomms." total comments on my blog"; ?> |
You can combine the code as well like following:
<?php $numcomms = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->comments WHERE comment_approved = '1'"); if (0 < $numcomms) $numcomms = number_format($numcomms); echo "There's ".$numcomms." total comments on my blog"; ?> |
This should show you that how many comments your blog has got.
Related Posts
sponsored links

[...] Click Here for More [...]
[...] Affichez le nombre total de commentaires sur votre blog (ok, [...]
[...] 7.显示回复的总数 [...]
Display the Total Number of Comments on Your WordPress Blog…
In this tutorial we will learn how to show total number of comments at your blog using the $wpdb object….
[...] 7.显示回复的总数 [...]
[...] Display the Total Number of Comments on Your WordPress Blog – PHP Magic Book [...]
[...] need to find appropriate place in your blog and paste the code. Here’s how you can display number of comment and trackback 6. Put Avatar On Your Comments – Gravatar/MyBlogLog/Twitter [...]
[...] 6. MOSTRAR O NÚMERO DE COMENTÁRIOS NO SEU BLOG As mostras de popularidade são uma forma eficiente de fazer o seu blog crescer ainda mais. Se por ventura recebe muitos comentários regularmente no seu blog, aprenda a apresentar esses números de forma dinâmica. [...]
[...] Displaying Total Number Of Comments, If you have a popular WordPress blog with good number of comments everyday, then wouldn’t it be nice to be able to display the total number of comments published on your WordPress blog since your blog launch? The kind of stuff advertisers totally enjoy. [...]
[...] 7.显示回复的总数 [...]
Thanks for your help on the comment feature using WordPress.
Tony
[...] 3.Display the Total Number of Comments on Your WordPress Blog [...]
[...] for PhpMagicBook for coming up with an easy way of showing the total number of [...]
[...] 1) Display the Total Amount of Comments on Your Blog [...]
[...] 1) Display the Total Amount of Comments on Your Blog [...]
[...] 1) Display the Total Amount of Comments on Your Blog [...]
[...] 1) Display the Total Amount of Comments on Your Blog [...]
[...] 1- Blogunuzdaki Toplam Yorum Sayısını Gösterin [...]
[...] 1- Blogunuzdaki Toplam Yorum Sayısını Gösterin [...]
[...] 1- Blogunuzdaki Toplam Yorum Sayısını Gösterin [...]
[...] 1- Blogunuzdaki Toplam Yorum Sayısını Gösterin [...]
Hey thanks, nice! Good way to show off how popular your blog is by the comments.
[...] 1) Display the Total Amount of Comments on Your Blog [...]
Good tut but I can’t stylize it. How can I make the numbers big and red?
[...] Displaying Total Number Of Comments On Your Blog (or trackbacks) If you have a popular WordPress blog with good number of comments everyday, then wouldn’t it be nice to be able to display the total number of comments published on your WordPress blog since your blog launch? The kind of stuff advertisers totally enjoy. [...]
[...] Displaying Total Number Of Comments On Your Blog (or trackbacks) If you have a popular WordPress blog with good number of comments everyday, then wouldn’t it be nice to be able to display the total number of comments published on your WordPress blog since your blog launch? The kind of stuff advertisers totally enjoy. [...]
[...] Click Here for More [...]
[...] 21. Display the Total Number of Comments [...]
@ragi: Just put all this code in a div block and give that div some style.
[...] thanks to PHP Magic Book for this awesome code. Related Posts:-How to Display Twitter Count in Plain TextHow to Display [...]
[...] Tutorial: Gesamtzahl Kommentare/Trackbacks ausgeben http://www.phpmagicbook.com/di.....ress-blog/ [...]
worked great and lets me thank all the readers and commentators, thanks!
Super-Duper site! I am loving it!! Will come back again – taking your feeds too now, Thanks.
I‘m sure many of you are like me and one of the first things you do in the morning is head here and check out the new post. Along with seeing the new posts, I’m also always checking out the blog roll rss feed and watching them grow, or shrink sometimes. In one of my past …but all in all excellent site. Keep it up!
[...] Displaying Total Number Of Comments On Your Blog (or trackbacks) If you have a popular WordPress blog with good number of comments everyday, then wouldn’t it be nice to be able to display the total number of comments published on your WordPress blog since your blog launch? The kind of stuff advertisers totally enjoy. [...]
,..] http://www.phpmagicbook.com is other interesting source of tips on this issue,..]
[...] Source… [...]
[...] Displaying Total Number Of Comments On Your Blog (or trackbacks) If you have a popular WordPress blog with good number of comments everyday, then wouldn’t it be nice to be able to display the total number of comments published on your WordPress blog since your blog launch? The kind of stuff advertisers totally enjoy. [...]
[...] Displaying Total Number Of Comments On Your Blog (or trackbacks) [...]
Thanks for the tip. But I want to show the total count of comments and trackbacks in the homepage. By default its showing only the comment count now. How can I do this?
Thanks in advance!
-Deepu
[...] This snippet comes from Hiroshi at PHP Magic Book [...]
[...] This snippet comes from Hiroshi at PHP Magic Book [...]
[...] This snippet comes from Hiroshi at PHP Magic Book [...]