How To Display The Average Number Of Your Subscribers

a minute read

Many bloggers use Feedburner to display the number of their subscribers. If you want to be able to show the average number of them over the past 7 days, here is the code that is useful for this purpose.
As usual, first of all you need to insert this function into the functions.php file of your theme:

1 function get_average_readers($feed_id,$interval = 7){
2     $today date('Y-m-d'strtotime("now"));
3     $ago date('Y-m-d'strtotime("-".$interval." days"));
4     $feed_url="".$feed_id."&dates=".$ago.",".$today;
5     $ch = curl_init();
6     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
7     curl_setopt($ch, CURLOPT_URL, $feed_url);
8     $data = curl_exec($ch);
9     curl_close($ch);
10     $xml new SimpleXMLElement($data);
11     $fb $xml->feed->entry['circulation'];
13     $nb = 0;
14     foreach($xml->feed->children() as $circ){
15         $nb += $circ['circulation'];
16     }
18     return round($nb/$interval);
19 }

Further, you can call this function anywhere on the site, but for this you need to specify id Feedburner as a parameter:

1 <?php
2 $nb = get_average_readers('wpincode');
3 echo "I have ".$nb." RSS subscribers";
4 ?>


Facebook Twitter LinkedIn Telegram Pocket

Related Posts:

Have you ever had a need to bring your fresh posts from each separate column to your WordPress sidebar? Recently, one of our users asked us if there was a way to quickly bring up fresh posts from a specific category to the WordPress sidebar widget. In today’s article, we will show you how to display the latest posts for each rubric in the WordPress sidebar. There are two ways to display fresh posts from each individual column in WordPress. The first method is really simple and convenient for...
If the content on your site is correctly organized by headings, then you probably will not need the block “Similar entries” on the site, because you can simply display fresh entries from the same heading. In today’s article, we will show you how to create a section called “More posts from this category,” as an alternative to “Related posts.” Show Me What You Have To Say If your records are organized correctly by rubrics, it may be useful to display a list of entries from the ru...
Recently, one of our users asked how to display a list of child pages for a page in WordPress. Often in the work on a site where there are child pages, you may need to show a list of these very child pages in the sidebar widget or anywhere else in the template. In this article, we will show you how to list the child pages for the parent in WordPress. You can look at an example of the list of child pages in the screenshot below, which was taken from the OptinMonster website page . An import...