WordPress’te twitter takip sayınızı paylaşınız.
Tarih : 20 / Kasım / 2014 - Kategori : Wordpress Kodları - Yorum Yok
WordPress template’nizin herhangi bir yerinde (sidebar, footer, header, index vb gibi) twitter takip sayınızı aşağıdaki kod ile gösterebilirsiniz.
Temanızın Function.php dosyasına aşağıdaki kodu yapıştırınız.
fdsf function update_twitter_count() { $name = 'problogdesign'; $url = 'http://api.twitter.com/1/users/show.xml?screen_name='. $name; $ch = curl_init(); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_URL, $url); $data = curl_exec($ch); curl_close($ch); $xml = new SimpleXMLElement($data); $count = $xml->followers_count; $count = (float) $count; $count = number_format($count); add_option('twitter_followers'); update_option('twitter_followers', $count); } function twitter_count() { echo get_option('tb_twitter_followers'); } if (!wp_next_scheduled('your_hourly_hook')) { wp_schedule_event(time(), 'hourly', 'your_hourly_hook'); } add_action('your_hourly_hook', 'update_twitter_count');
ve twitter takip sayınızı göstermek istediğiniz alanada aşağıdaki kodu yapıştırmanız yeterli olacaktır.
<?php twitter_count(); ?>