how to display rss readers on your wordpress

how to display rss readers on your wordpress

you can display rss readers on your wordpress using following code. Many wordpress blogger want to show the information RSS  readers of their site.  We given code here in this article.

how to display rss readers on your wordpress

Showing the RSS feed information to your user is good for seo and smo.

Just following code in your functions.php file.


function get_rss_readers($feed_id,$interval = 7){
$today_date = date('Y-m-d', strtotime("now"));
$ago = date('Y-m-d', strtotime("-".$interval." days"));
$feed_url="https://feedburner.google.com/api/awareness/1.0/GetFeedData?uri=".$feed_id."&dates=".$ago.",".$today_date;
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $feed_url);
$data = curl_exec($ch);
curl_close($ch);
$xml = new SimpleXMLElement($data);
$fb = $xml->feed->entry['circulation'];

$rss_readers = 0;
foreach($xml->feed->children() as $circ){
$rss_readers += $circ['circulation'];
}

return round($rss_readers/$interval);
}

In sidebar.php or where you want to show your rss feed reader count there you should use the following code.

$rss_readers = get_rss_readers('wordpressapi');
echo "We currently have ".$rss_readers." RSS readers";

Published by

Purab

I am Purab from India, Software development is my profession and teaching is my passion. Programmers blog dedicated to the JAVA, Python, PHP, DevOps and Opensource Frameworks. Purab's Github Repo Youtube Chanel Video Tutorials Connect to on LinkedIn

Leave a Reply

Your email address will not be published.