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

November 27, 2009  | 
1 Comment

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.

<?php
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}
		{$where}
		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;
  $insertion_length=strlen($long_string)-strlen($short_string);
  for($i=0;$isaveHTML();
  $element->parentNode->removeChild($element);
  $html2=$document->saveHTML();
  return string_getInsertedString($html,$html2,true);
}
function getFollowers($username){
  $x = file_get_contents("http://twitter.com/".$username);
  $doc = new DomDocument;
  @$doc->loadHTML($x);
  $ele = $doc->getElementById('follower_count');
  $innerHTML=preg_replace('/^<[^>]*>(.*)<[^>]*>$/',"\\1",DOMElement_getOuterHTML($doc,$ele));
  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:

http://yourwpblog.com/?author=6,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:

<?php
$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.

<?php
$fburl=”https://feedburner.google.com/api/awareness/1.0/GetFeedData?uri=YourURL“;
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $fburl);
$stored = curl_exec($ch);
curl_close($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

Featured Plugin - Every great SEO tweak you need, in one snazzy bundle

Fully integrated with the SEOMoz API, complete with automatic links, sitemaps and SEO optimization of your WordPress setup - this is the only plugin you need to help you rank your site number 1 on Google - nothing else compares.
Find out more

Featured Plugin - Send beautiful html email newsletters, from WordPress!

Now there's no need to pay for a third party service to sign up, manage and send beautiful email newsletters to your subscriber base - this plugin has got the lot.
Find out more

Featured Plugin - WordPress + Google Maps = Perfect

Simply insert google maps into posts, sidebars and pages - show directions, streetview, provide image overlays and do it all from a simple button and comprehensive widget.
Find out more

Featured Plugin - Turn any WordPress page into a fully featured wiki!

To get a wiki up and running you used to need to install Mediawiki and toil away for days configuring it... not any more! This plugin gives you *all* the functionality you want from a wiki, in WordPress!!!
Find out more

Featured Plugin - Host sites, get paid, just like WordPress.com

If you've ever wondered how you could offer a paid site management and hosting service, then this is the plugin for you. Offer a freemium or paid service, for any niche you like, it's powered Edublogs.org to success already!
Find out more

Featured Plugin - Open an Online Store with MarketPress

Out of all the WordPress ecommerce plugins available, this has got to be the winner - easy to configure, powerful functionality, multiple gateways and more. A simply brilliant plugin!
Find out more

Featured Plugin - Start your own Quora / StackOverflow / Yahoo Q&A site

It's now incredibly easy to start your own Q&A site using nothing more than WordPress - The Q&A plugin simply and brilliantly transforms any site, or page, into a perfect support or Q&A environment.
Find out more

Featured Plugin - Start Your Own Powerful Membership Site

If you're thinking about starting a paid, or just private, membership site then this is truly the plugin you've been looking for. Easy to use, massively configurable and ready to go out of the box!
Find out more

Featured Plugin - Easily integrate your WordPress site with Facebook

Would you like to add Facebook comments, registration, 'Like' buttons and autoposting to your WP site? Well, The Ultimate Facebook plugin has got that all covered!
Find out more

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

  1. Pingback: Present Tensed / rasml.org

Click on a tab to select how you'd like to leave your comment

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Subscribe without commenting