display total comment trackback geekact

Now this one is really cool and simple. You can display total comments and trackbacks made on your blog using some simple copy-paste codes. You can see at top-right corner of my blog that how different look and show-off you can give to your blog by using this.

display total comment trackback geekact

It involves editing your wordpress theme files. So first thing is to backup. Again as seen in Floating share bar guide; you can use it in on whole site, just main page or just posts.

If you want it for whole site and at top then best choice would be ‘header.php’ file. For posts, I would have preferred ‘single post. php’ file and for just main page go with ‘Main Index php’ file. You can also put this code in sidebars. You won’t be able to use it widgets but you can edit ‘sidebar php’ file and paste this code there.

Only problem is choosing the location when you want this stuff in header. It should be pasted after the logo and before header ends. There can be Sliders and Menus in between so you will need to choose location by trial and error.

First thing; backup the file you are going to edit. Then copy-paste this code in your file (present in theme’s folder);

<div class="comment-total">
   <?php $numcomms = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->comments WHERE comment_approved = '1'"); 
       if (0 < $numcomms) $numcomms = number_format($numcomms); echo "Awesome <span>".$numcomms."</span> Comments";?>
</div>
<div class="trackback-total">
   <?php $numcomms = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->comments WHERE comment_type = 'pingback' OR 'trackback'"); echo "<span>".$numcomms."</span> Total Trackbacks";?>
</div>

You can remove trackbacks code if you don’t want it.

Now what about little styling so that you change the font, color, size etc of displayed text?

Add this in end of your theme’s ‘stylesheet css’ file;

/*comment total stlying*/
.comment-total{text-align: right;font-size: 1.1em;color: #FFFFCC;}
.comment-total span{font-size: 1.5em;color: #FF0000;}
.trackback-total{text-align: right;font-size: 1.1em;color: #FFFFCC;}
.trackback-total span{font-size: 1.5em;color: #FF0000;}

You can modify it as per your wish to suit your site’s theme.

I hope this worked for you. Comments and issues are welcome!

Creative Commons License
Showing Off Total Comments and Trackbacks on WordPress Blog by Mrinal Buddekar is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.

By Mrinal Buddekar

Data Manager and a technology enthusiast! Mrinal Buddekar is Pune based blogger who loves building server, websites, technology, and affiliate blogging.

Hey there!

Help us reach out to awesome people lie you out there. We publish Tech and WordPress, Deals, and Reviews. WE DON'T SPAM!

Your Information will never be shared with any third party