Create A Sidebar Widget To Display Your Feedburner Stats In WordPress

If you hadn’t noticed already, we have added a nifty little sidebar widget and a post footer banner to showoff how many of you have subscribed to our blog. So today we will show you how to create your own!

All you will require is a little knowledge of PHP and the following enabled.

Part 1

Executable PHP widget (If you are not running WordPress, this is not required as it works just fine without)

Enable the Awareness API in your Feedburner settings by pressing on the Publicize tab > Awareness API > Activate.

If you are running XAMPP or the equivalent you will need to enable CURL support in your php.ini by finding the following and removing the ;.

extension=php_curl.dll

Most, if not all web hosts should already have this enabled. In the off chance they do not, you will have to get in touch with them.

Once this is all sorted you are ready to show off your Feedburner stats.

Part 2

Creating the Feedburner Sidebar Widget

The CSS – This will need adding into your WordPress’s theme stylesheet.

#show-rss {
width:300px;
 height:125px;
 background:url(images/abstract-orange-rss.jpg) no-repeat;
 }

#show-rss .rss ul li{
 padding:58px 0 0 66px;
 list-style-type:none;
 text-decoration:none;
 }

.li_rss{

 font-size:36px;
 color:#cc6b24;
 font-family:Arial, Helvetica, sans-serif;
 }

The PHP – You can either paste this into your recently installed Executable PHP widget or insert directly into your sidebar.php.

<?php
//Where it says YourFeedburnerID, replace with the name of your feed. For example ours is nenunocreative
$url = "https://feedburner.google.com/api/awareness/1.0/GetFeedData?uri=YourFeedburnerID";

$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $url);
$data = curl_exec($ch);
curl_close($ch);
if ($data) {
 echo $data;
 //filters unwanted characters
 preg_match('/circulation=\"([0-9]+)\"/',$data, $matches);
 if ($matches[1] != 0) {
 $rsscount = $matches[1];
 }
}
?>
<a href="http://feedburner.google.com/fb/a/mailverify?uri=YourFeedburnerID" target="_blank" style="text-decoration:none;" border="0">

<div id="show-rss">

 <div>

<ul><li>

 <?php
 //Prints the number of Feedburner Subscribers
 echo "$rsscount";
 ?>

</li>

</ul></div>
</div></a>

Once you have updated YourFeedburnerID you may now post the PHP into a newly created sidebar widget as shown below:

The last thing you need to do is just upload the below into your Themes image directory:

And you are done! Now go check out your new Feedburner Stats Widget!

Live Demo

Optional

This is optional, but if you would like to showcase your Feedburner stats at the bottom of your posts you just need to amend the CSS.

The CSS:

#large-show-rss {
 width:600px;
 height:125px;
 background:url(images/large-abstract-orange-rss.jpg) no-repeat;
 }

#large-show-rss .large-rss ul li{
 padding:69px 0 0 300px;
 list-style-type:none;
 text-decoration:none;
 }

.li_large-rss{

 font-size:30px;
 color:#E37A2D;
 font-family:Arial, Helvetica, sans-serif;
 }

The PHP with a little HTML:

<?php
 //Where it says YourFeedburnerID, replace with the name of your feed. For example ours is nenunocreative
$url = "https://feedburner.google.com/api/awareness/1.0/GetFeedData?uri=YourFeedburnerID";
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $url);
$data = curl_exec($ch);
curl_close($ch);
if ($data) {
 echo $data;
//filters unwanted characters
 preg_match('/circulation=\"([0-9]+)\"/',$data, $matches);
 if ($matches[1] != 0) {
 $rssount = $matches[1];
 }
}

?>
 <a href="http://feedburner.google.com/fb/a/mailverify?uri=YourFeedburnerID" target="_blank" style="text-decoration:none;" border="0">
<div id="large-show-rss">

 <div>

<ul><li><?php

//Prints the number of Feedburner Subscribers
echo "$rsscount";

?></li>

</ul></div>
</div></a>

The last thing you need to do is just upload the below into your Themes image directory:

Open single.php and paste the mixture of PHP and HTML into where you wish the footer to show under your posts.

4 Comments

  1. Wow thanks for this tutorial! It will help my blog gain more rss subscribers ( I hope) as it is more attractive now :)

  2. Feedburner is really very useful for syndicating feeds from other websites.~-*

Leave a Reply

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