Ditching the chicklet
One of my big goals when redoing my layout was to get rid of that uniform, ugly little image that Feedburner provides us to display our RSS e-peen. Rather than having the gross icon taking up some space on my sidebar, I wanted to display my subscriber count as plain text and thus format it however I pleased.
After trying a metric ton of different options and code snippets I finally found one that worked and I’d like to share it with my fellow WoW blogging buddies out there.
NB: This requires you being able to edit a php file in your layout. I inserted this code into the sidebar.php portion of my design (with heavy tweaking). Not sure if WordPress.com or Blogspot allow access to such a file, though any self-hosted blogs should have no problem utilizing this solution.
Here’s the code:
<?php $url = "https://feedburner.google.com/api/awareness/1.0/ GetFeedData?uri=FEEDBURNERNAME"; $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; preg_match('/circulation=\"([0-9]+)\"/',$data, $matches); if ($matches[1] != 0) { $subscriberCount = $matches[1]; } } echo "$subscriberCount" ?>
Just replace “FEEDBURNERNAME” with the username you have with that service. Mine is RighteousDefense, for example. You can get your username just by looking at your Feedburner URL.
The code block will return your total subscriber number as text. Surround it with whatever flavor you want.
I hope this works for everyone and allows you to finally ditch that awful chicklet!
@iamapaladin
29 April 2010 at 4:58 pm #
Hmmm, I might use this..
HP’s last blog ..Interesting Statistics to Me about Me
I don’t show my RSS reader count. I’m not so sure it’s meaningful unless you have >500 readers or something massive like that.
Alright, seeing it live here sold me. I like it. ;) Is the code above the final working version so I could use it too?
Strangely when I tried adding it via my PHP Code sidebar widget, it didn’t save.
Oh I suggest you change the “edit time allowed”, it is too short. Locked me out of the above.
@Rhidach
4 May 2010 at 5:24 pm #
I tried to insert it with a widget (though the default one via the WP admin panel) and finally just inserted the code myself into sidebar.php in my theme, and that worked like a charm.