Creating a twitter widget in the Wordpress function.php file


/ Published in: PHP
Save to your folder(s)

I found this code for adding a custom twitter widget to your functions file, it's been useful on more that a few occasions. So thought I would add it to the blog as well as development. As the code needs the twitter_update_list ID it's not possible to put more than one of these on a page so I haven't made it into a multiple widget.


Copy this code and paste it in your HTML
  1. <?php function widget_mytheme_twitter() { ?>
  2. <div>
  3. <ul><li><h2><a href="http://twitter.com/MYTWITTER">My Twitter Feed</a></h2>
  4. <ul id="twitter_update_list" ><li><script type="text/javascript" src="http://twitter.com/javascripts/blogger.js"></script>
  5. <script type="text/javascript" src="http://twitter.com/statuses/user_timeline/MYTWITTER.json?callback=twitterCallback2&amp;count=5"></script></li></ul>
  6. </li></ul></div>
  7. <?php } if ( function_exists('register_sidebar_widget') )
  8. register_sidebar_widget(__('Twitter feed'), 'widget_mytheme_twitter'); ?>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.