I am using Feedburner counter with text in most of my WordPress themes. Recently, I found that they are not working properly due to the conversion of Feedburner to Google FeedProxy. Today, I found a solution thanks to one of my theme user. I will show you how to do that.
I am using Feedburner counter with text in most of my WordPress themes. Recently, I found that they are not working properly due to the conversion of Feedburner to Google FeedProxy. Today, I found a solution thanks to one of my theme user. I will show you how to do that. I will use the feed.php in my premium theme – Our Community. If you are still using Feedburner service, then you can ignore this tutorial. This is just for those who are using Google FeedProxy.
The Existing Feed File.
<?php
$last_update = intval(get_option('feed_lastupdate'));
$now = time();
if(($now - $last_update) > (60*60*24)) :
//get cool feedburner count
$feed = get_option('feed');
$whaturl="http://api.feedburner.com/awareness/1.0/GetFeedData?uri=$feed";
//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'];
if(!$fb) :
$fb = 0;
endif;
update_option("feed_count", $fb."");
//end get cool feedburner count
update_option("feed_lastupdate", $now."");
endif;
$feed_uri = get_option('feed');
if(!$feed_uri or $feed_uri == '') :
$feed_uri = get_bloginfo('rss2_url');
else :
$feed_uri = 'http://feeds.feedburner.com/' . $feed_uri;
endif;
?>
<a href="<?php echo $feed_uri; ?>" title="Feed Subscriber Count"><?php echo get_option("feed_count");?></a>
Editing
Change this:
$whaturl="http://api.feedburner.com/awareness/1.0/GetFeedData?uri=$feed";
Into This:
$whaturl="https://feedburner.google.com/api/awareness/1.0/GetFeedData?uri=$feed";
And this:
$feed_uri = 'http://feeds.feedburner.com/' . $feed_uri;
Into This:
$feed_uri = 'http://feedproxy.google.com/' . $feed_uri;
Full Code:
<?php
$last_update = intval(get_option('feed_lastupdate'));
$now = time();
if(($now - $last_update) > (60*60*24)) :
//get cool feedburner count
$feed = get_option('feed');
$whaturl="https://feedburner.google.com/api/awareness/1.0/GetFeedData?uri=$feed";
//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'];
if(!$fb) :
$fb = 0;
endif;
update_option("feed_count", $fb."");
//end get cool feedburner count
update_option("feed_lastupdate", $now."");
endif;
$feed_uri = get_option('feed');
if(!$feed_uri or $feed_uri == '') :
$feed_uri = get_bloginfo('rss2_url');
else :
$feed_uri = 'http://feedproxy.google.com/' . $feed_uri;
endif;
?>
<a href="<?php echo $feed_uri; ?>" title="Feed Subscriber Count"><?php echo get_option("feed_count");?></a>
Share it!
('
¡¯)
Try this
http://wordpress.org/extend/plugins/feedburner-text-counter-v10/
(: