This tutorial shows you how to add your latest Tweet to your WordPress website. It’s fast and easy, and lets you broadcast your Twitter activity to your readers.
While working on the redesign of my website I realized I was using a very inefficient method of displaying my latest Twitter post (“Tweet”). Currently I’m using a script I found online that uses two functions that are just over 20 lines of code total. Here I’ll show you how to use WordPress’ built in RSS parser to display your latest tweet in 5 lines of code (thus this will only work on WordPress).
Note: An important aside about this script is that by default WordPress caches the feed for 1 hour. This means your Tweet on your website will be updated at that frequency. This is great because it saves your server a lot of overhead, especially on busy website. However, if you’re an avid Twitterer and want your very latest Tweet shown for every page refresh for every visitor, I recommend using this method.
Past the above in your functions.php file. Now just paste the following in your theme file where you want your Twitter post to appear:
Obviously replace my username with yours. Now you’re done! Style it however you like with HTML and CSS.
If you’d like to show more then one tweet, here is an updated version of this function: http://jhnk.pastebin.com/5A4aXYTW