The first thing you need to do is create a file called feed.php. Copy the code below into the file you just created.
The Code – Displaying your RSS Feed count
<?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; ?>
Once you have pasted this section of code into your new feed.php file, there is another important step you MUST take in order for it to work.
Input your Feedburner ID
On line 3 of the code above you have to change a bit of code. You must change this code so that it reads your Feedburner ID instead of Feed Here which is just a place holder. See correct example below.
$whaturl="https://feedburner.google.com/api/awareness/1.0/GetFeedData?uri=ThreeStyles";
Your Feedburner ID is what is at the end of your Feeds URL so DO NOT FORGET to insert that there or the feed count will not work.
Don’t forget the Include
The last step to getting your count to display is using a PHP include statement to include the code we copied above into the actual page. On my blog I included my code into the sidebar because that happened to be where I had space. So in my sidebar.php I used the code below.
Time for the Styles!!
Now we have our code coming into the sidebar but it is as plain as plain can be right?
Remember I’m doing this tutorial based on the subscribe button in the top right corner of the sidebar. So first I am going to open my sidebar.php file or whatever file you placed the Include statement in. We are now going to add two divs around our include statement as shown below.
<div id="feedcount"><a href="http://feeds.feedburner.com/ThreeStyles"></a> <p><?php include("feed.php"); ?></p> </div>
Original post from:
http://www.threestyles.com/tutorials/add-a-custom-feedburner-count-to-your-wordpress-blog/
Be First to Comment