شاید دوست داشته باشید که تعداد دنبال کنندگان feedburner سایت خود را در بخشی از پوسته نمایش دهید .
برای اینکار می توانید از توابع get_transient و wp_remote_get به شکل زیر در فایل functions.php استفاده کنید :
function feed_subscribers(){ $feed_url = 'https://feeds.feedburner.com/yourname'; $count = get_transient('feed_count'); if ($count != false) return $count; $count = 0; $data = wp_remote_get('https://feedburner.google.com/api/awareness/1.0/GetFeedData?uri='.$feed_url.''); if (is_wp_error($data)) { return 'error'; }else{ $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; }
برای نمایش نتیجه این تابع در مکان دلخواه پوسته خود نیز از کد زیر استفاده کنید :
<?php feed_subscribers(); ?>
نظر شما چیست