Show Me the Numbers: 7 Handy Hacks to Display Your Best Numbers on Your Blog

Show Me the Numbers: 7 Handy Hacks to Display Your Best Numbers on Your Blog

numbersInformation is power, and knowing is half the battle. There are lots of ways to show your good numbers. Maybe you want to highlight a successful blog or author to get others inspired and motivate more people to join in. Bandwagoning has been a classic advertising technique for hundreds of years. Your good numbers will speak for themselves. You want to be able to promote and leverage your best material in a way that will engender a sense of community. Use these hacks to highlight where people are interacting with this website. Give your users the impression that what’s happening on your site is important, and they won’t want to be the only ones missing this information. We’ve put together a list of seven simple hacks to have you showing your good numbers in no time. If you use all of these, it will definitely be overload, so use sparingly and select the best hacks that will enhance your site.

Display Registered Users’ Comment Count on Your WP blog:

How to use: Simply paste this code inside your template files wherever you want to use it.

global $wpdb;
$where = 'WHERE comment_approved = 1 AND user_id <> 0';
$comment_counts = (array) $wpdb->get_results("
		SELECT user_id, COUNT( * ) AS total
		FROM {$wpdb->comments}
		GROUP BY user_id
	", object);
foreach ( $comment_counts as $count ) {
  $user = get_userdata($count->user_id);
  echo 'User ' . $user->display_name . ' comment count is ' . $count->total . '

Link to Source

Display Total Number of Twitter Followers:

How to Use: Paste the first section of code in your theme’s functions.php files and then paste the second one anywhere in your template files. Make sure to replace my username with yours.

function string_getInsertedString($long_string,$short_string,$is_html=false){
  if($short_string>=strlen($long_string))return false;

  if($is_html && $inserted_string[$insertion_length-1]=='<'){

  return $inserted_string;

function DOMElement_getOuterHTML($document,$element){

  return string_getInsertedString($html,$html2,true);

function getFollowers($username){
  $x = file_get_contents("".$username);

  $doc = new DomDocument;
  $ele = $doc->getElementById('follower_count');

  return $innerHTML;

<?php echo getFollowers("pollyplummer")." followers"; ?>

Link to Source

Display specific author’s posts

How to Use: Get the IDs of the authors you’d like to list the posts. In this example, I want to list posts from authors 1 and 6.

Simply type the following in your browser address bar:,1

You can add more authors, simply separate all IDs with a comma.

Link to Source

Display Number of Search Results:

How to Use: Open your search.php file and look for the following:

<h2 class="pagetitle">Search Results</h2>

Replace it with this:

<h2 class="pagetitle">Search Results for <?php /* Search Count */ $allsearch = &new WP_Query("s=$s&showposts=-1"); $key = wp_specialchars($s, 1); $count = $allsearch->post_count; _e(''); _e('<span class="search-terms">'); echo $key; _e('</span>'); _e(' — '); echo $count . ' '; _e('articles'); wp_reset_query(); ?></h2>

Link to Source

Display Average Comments Per Post:

How to Use: Paste this code anywhere in your template files where you want the average comments per post to show:

$count_posts = wp_count_posts();
$posts = $count_posts->publish;

$count_comments = get_comment_count();
$comments  = $count_comments['approved'];

echo "Average ".round($comments/$posts)." comments per post.";

Link to Source

Display Feedburner Count:

How to Use: Paste this piece of code anywhere in your template files where you want to show your Feedburner numbers.

$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $fburl);
$stored = curl_exec($ch);
$grid = new SimpleXMLElement($stored);
$rsscount = $grid->feed->entry['circulation'];
echo $rsscount;

Link to Source

Display Total Number of Trackbacks:

How to Use: First create a function by adding this to your functions.php file:

function tb_count() {
    global $wpdb;
	$count = "SELECT COUNT(*) FROM $wpdb->comments WHERE comment_type = 'pingback' OR comment_type = 'trackback'";
    echo $wpdb->get_var($count);

Then call the function anywhere you want in your template files:

<?php tb_count(); ?>

Link to Source