Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
WordPress Transient Feedburner
function feed_subscribers(){
$feed_url = '';
$count = get_transient('feed_count');
if ($count != false) return $count;
$count = 0;
$data = wp_remote_get(''.$feed_url.'');
if (is_wp_error($data)) {
return 'error';
$body = wp_remote_retrieve_body($data);
$xml = new SimpleXMLElement($body);
$status = $xml->attributes();
if ($status == 'ok') {
$count = $xml->feed->entry->attributes()->circulation;
} else {
$count = 300; // fallback number
set_transient('feed_count', $count, 60*60*24); // 24 hour cache
echo $count;
Copy link

This is gist is created by Abhishek Ghosh for the blog article WordPress Transients For Caching Social Media Counts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment