How To Display RSS and Twitter Count in Plain Text

by Alex

Here is a neat trick to making your blog look better. I hate seeing those default Feedburner and Twittercounter chicklets on other people’s blog, because they look so ugly. No matter what color you change them, they never look nice. So, wouldn’t a neat trick be to display these counter on your own terms?

As you can see here on Blogussion, at the top nav menu there is the count for both RSS and the Blogussion Twitter followers. I like to have them display as text because I can easily customize the looks of them on my own terms.

Why text is better than a chicklet

When you change to the text form, I almost guarantee you will see more conversions and will gain new subscribers – if you do it right!

The real perk of using this text block is that it just shows the number of followers/subscribers you have. That means you are free to add any kind of text you want before or after that count. The real trick here is how to hook people in to clicking that link and subscribing to your feed or following you on Twitter.

A simple example of what may be a good catch to sign up would be something like “Come join 1,568 other people who are learning about blogging.” It’s simple, catchy and it shows that there are a number of people who are learning about blogging by reading from your blog.

Displaying RSS Count

Create a new file, name it feed.php and paste the following into it:

<?php
//get cool feedburner count
$whaturl="https://feedburner.google.com/api/awareness/1.0/GetFeedData?uri=Feed Here";

//Initialize the Curl session
$ch = curl_init();

//Set curl to return the data instead of printing it to the browser.
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

//Set the URL
curl_setopt($ch, CURLOPT_URL, $whaturl);

//Execute the fetch
$data = curl_exec($ch);

//Close the connection
curl_close($ch);
$xml = new SimpleXMLElement($data);
$fb = $xml->feed->entry['circulation'];
//end get cool feedburner count

echo $fb;

?>

Edit the line at the very top with the name of your feed. For example, I would put “Blogussion” on the line. Then just simply add this line of code wherever you want the count to display: <?php include("feed.php"); ?>

Script found on Hongkiat.com

Displaying Twitter Count

Create a file called twitter.php and paste the following code into it:

<?php
$tw = get_option("twitterfollowerscount");
if ($tw['lastcheck'] < ( mktime() - 3600 ) )
{
$xml=file_get_contents('http://twitter.com/users/show.xml?screen_name=Feed here');
if (preg_match('/followers_count>(.*)</',$xml,$match)!=0) {
$tw['count'] = $match[1];
}
$tw['lastcheck'] = mktime();
update_option("twitterfollowerscount",$tw);
}
echo $tw['count'];
?>
Script found at WP Recipes

Again, edit what’s in bold to your Twitter name and paste this code wherever you want the count to display: <?php include("twitter.php"); ?>

So those are two coll little tricks that really make a difference on your blog. Let me know what you guys think of using this trick, let alone sharing the number of subscribers on your blog.

Photo by Stephen Coles

Back to the top

by

To learn more about this author and see all of their posts, click below.

View Full Profile →

Discover the Real Meaning...

of what it means to master the psychology of your blogging practice. Find out one of the most missed aspects to blogging now, totally free!

Comments on this entry are closed.

Previous post:

Next post: