10 Twitter Hacks For Your WordPress Blog

Twitter has grown exponentially in the past few months and Still, It’s growing like crazy. Twitter has surpassed Facebook and others to become the fastest-growing site in the “Member Communities” category. Twitter is a powerful marketing and promotion tool that no active blogger can ignore.

The “Twitter effect” is on the rise day by day. For all those who haven’t yet heard of it, Twitter is a free social networking and micro-blogging service that allows its users to send and read “updates” (otherwise known as tweets) to their webpage using SMS,IM or other 3rd part applications, which are text-based posts of up to 140 characters in length.

In this article, we have compiled 10 most useful Twitter hacks and tips for your WordPress blog to help you get the most out of Twitter.

You may be interested in the following related articles as well.

Feel free to join us and you are always welcome to share your thoughts that our readers may find helpful.

Don’t forget to subscribe to our RSS-feed and follow us on Twitter — for recent updates.

10 Twitter Hacks For Your WordPress Blog

01. Create a “Twitter This” Button for WordPress Posts

InstantShift - Twitter Hacks For Your WordPress Blog

Creating a “Tweet This” button for your blog posts are fairly very easy. Use this following code on your single.php file, within the loop to create a button. This is the basic code for a typical “Twitter This” Button, you can use some images or CSS styling to make it more attractive. Possibilities are endless.

<a href="http://twitter.com/home?status=Currently reading <?php the_permalink(); ?>" title="Send this page to Twitter!" target="_blank">Spread on Twitter</a>

02. Automatically Create TinyUrls for Your Tweets

InstantShift - Twitter Hacks For Your WordPress Blog

You have to use a URL shortening services when tweeting URLs because of 140 characters restriction in Twitter. For that purpose you can use tinyurls, because tinyurl provides an API, which takes over this task easily and generates unique tinyurls for your blog posts automatically.

To use tinyurl API, edit your functions.php file and paste the following function code:

function getTinyUrl($url) {
  $tinyurl = file_get_contents("http://tinyurl.com/api-create.php?url=".$url);
  return $tinyurl;
}

Now in your single.php file, paste the following within the loop:

<?php
  $turl = getTinyUrl(get_permalink($post->ID));
  echo 'Tiny Url for this post: <a href="'.$turl.'">'.$turl.'</a>'
?>

03. Displaying Total Number Twitter Followers on WordPress

InstantShift - Twitter Hacks For Your WordPress Blog

You are actively using Twitter from last few weeks and the numbers of followers are increasing regularly. So you are looking for way to display total number of your Twitter followers on your blog and update automatically. You can use this piece of code to display your followers anywhere you want, may be you want to display this number in author info in your blog posts.

Open functions.php and paste this php function there.

function string_getInsertedString($long_string,$short_string,$is_html=false){
  if($short_string>=strlen($long_string))return false;
  $insertion_length=strlen($long_string)-strlen($short_string);
  for($i=0;$i<strlen ($short_string);++$i){
    if($long_string[$i]!=$short_string[$i])break;
  }
  $inserted_string=substr($long_string,$i,$insertion_length);
  if($is_html && $inserted_string[$insertion_length-1]=='<'){
    $inserted_string='<'.substr($inserted_string,0,$insertion_length-1);
  }
  return $inserted_string;
}

function DOMElement_getOuterHTML($document,$element){
  $html=$document->saveHTML();
  $element->parentNode->removeChild($element);
  $html2=$document->saveHTML();
  return string_getInsertedString($html,$html2,true);
}

function getFollowers($username){
  $x = file_get_contents("http://twitter.com/".$username);
  $doc = new DomDocument;
  @$doc->loadHTML($x);
  $ele = $doc->getElementById('follower_count');
  $innerHTML=preg_replace('/^< [^>]*>(.*)< [^>]*>$/',"\\1",DOMElement_getOuterHTML($doc,$ele));
  return $innerHTML;
}

Now simply use this code to display total number of your Twitter followers. Just replace our username (instantshift) with yours.

<?php echo getFollowers("instantshift")." followers"; ?>

Of course you can further style it with CSS. You can also try some fancy background images or twitter bird. For example.

<span style="background:#C00;border:#FFF 1px solid;color:#FFF;font-family:'Myriad Pro',Helvetica,Arial,sans-serif;font-size:28px;padding:10px 20px;font-weight:bold;width:auto;">Proudly Followed by <?php echo getFollowers("google"); ?> Followers</span>

04. Use Twitter Avatars in Comments

InstantShift - Twitter Hacks For Your WordPress Blog

Thousands of blogs show avatars next to their user’s comments. The avatars are a great way to make things more personal and create some variety between the different comments. You can display Twitter avatars in your WordPress comments, instead of gravatars. Smashing Magazine provided fairly easy way to integrates Twitter avatars on your comments.

The first thing you need to do is to get the functions file here. Once you downloaded the file, unzip the archive and open the twittar.php file. Select all its content and paste it into functions.php. Finally you will need to enable Twitter avatars in your comments.php file. Edit comments.php and past this code in comments loop. Now you are ready with Twitter avatars.

<?php twittar('45', 'default.png', '#e9e9e9', 'twitavatars', 1, 'G'); ?>

05. Display Your Most Recent Twitter Entry

InstantShift - Twitter Hacks For Your WordPress Blog

Here is a small script for WordPress blog that allows us to pull the latest tweet from a Twitter user via the RSS feed that is produced by Twitter. We are also able to set a prefix and a suffix for the tweet for further customization.

<?php
$username = "TwitterUsername"; // Your twitter username.
$prefix = ""; // Prefix - some text you want displayed before your latest tweet.
$suffix = ""; // Suffix - some text you want display after your latest tweet.
$feed = "http://search.twitter.com/search.atom?q=from:" . $username . "&rpp=1";

function parse_feed($feed) {
$stepOne = explode("<content type=\"html\">", $feed);
$stepTwo = explode("</content>", $stepOne[1]);
$tweet = $stepTwo[0];
$tweet = str_replace("&lt;", "<", $tweet);
$tweet = str_replace("&gt;", ">", $tweet);
return $tweet;
}

$twitterFeed = file_get_contents($feed);
echo stripslashes($prefix) . parse_feed($twitterFeed) . stripslashes($suffix);
?>

06. Display X Number of Your Latest Twitter Entries

InstantShift - Twitter Hacks For Your WordPress Blog

Now we are going to introduce the ability to pull numerous tweets. With limits set in the Twitter API, we can pull anywhere from 1 to 100. Though it is nice to be able to pull so many, we have to remember that the more we pull, the longer it will take for this script to generate its content.

<?php
$username = "TwitterUsername"; // Your twitter username.
$limit = "5"; // Number of tweets to pull in.

/* These prefixes and suffixes will display before and after the entire block of tweets. */
$prefix = ""; // Prefix - some text you want displayed before all your tweets.
$suffix = ""; // Suffix - some text you want displayed after all your tweets.
$tweetprefix = ""; // Tweet Prefix - some text you want displayed before each tweet.
$tweetsuffix = "<br>"; // Tweet Suffix - some text you want displayed after each tweet.

$feed = "http://search.twitter.com/search.atom?q=from:" . $username . "&rpp=" . $limit;

function parse_feed($feed, $prefix, $tweetprefix, $tweetsuffix, $suffix) {

$feed = str_replace("&lt;", "<", $feed);
$feed = str_replace("&gt;", ">", $feed);
$clean = explode("<content type=\"html\">", $feed);

$amount = count($clean) - 1;

echo $prefix;

for ($i = 1; $i <= $amount; $i++) {
$cleaner = explode("</content>", $clean[$i]);
echo $tweetprefix;
echo $cleaner[0];
echo $tweetsuffix;
}

echo $suffix;
}

$twitterFeed = file_get_contents($feed);
parse_feed($twitterFeed, $prefix, $tweetprefix, $tweetsuffix, $suffix);
?>

07. Display Tweets From Multiple Users

InstantShift - Twitter Hacks For Your WordPress Blog

Now what you are looking for? Maybe you want to pull multiple tweets from multiple user accounts and display them. With the code below, you are able to define what you want before the Twitter block, after the Twitter block, before and after each individual tweet, and after the displayed user name. You can also turn off the displayed user names if you are looking to show all of your own personal tweets from multiple accounts!

<?php
$usernames = "Username Username Username"; // Pull from accounts, separated by a space
$limit = "5"; // Number of tweets to pull in, total.
$show = 1; // Show username? 0 = No, 1 = Yes.

$prefix = ""; // This comes before the entire block of tweets.
$prefix_sub = ""; // This comes before each tweet on the feed.
$wedge = ""; // This comes after the username but before the tweet content.
$suffix_sub = "<br>"; // This comes after each tweet on the feed.
$suffix = ""; // This comes after the entire block of tweets.

function parse_feed($usernames, $limit, $show, $prefix_sub, $wedge, $suffix_sub) {

$usernames = str_replace(" ", "+OR+from%3A", $usernames);
$feed = "http://search.twitter.com/search.atom?q=from%3A" . $usernames . "&rpp=" . $limit;
$feed = file_get_contents($feed);
$feed = str_replace("&", "&", $feed);
$feed = str_replace("<", "<", $feed);
$feed = str_replace(">", ">", $feed);
$clean = explode("<entry>", $feed);
$amount = count($clean) - 1;

for ($i = 1; $i <= $amount; $i++) {

$entry_close = explode("</entry>", $clean[$i]);
$clean_content_1 = explode("<content type=\"html\">", $entry_close[0]);
$clean_content = explode("</content>", $clean_content_1[1]);
$clean_name_2 = explode("<name>", $entry_close[0]);
$clean_name_1 = explode("(", $clean_name_2[1]);
$clean_name = explode(")</name>", $clean_name_1[1]);
$clean_uri_1 = explode("<uri>", $entry_close[0]);
$clean_uri = explode("</uri>", $clean_uri_1[1]);

echo $prefix_sub;
if ($show == 1) { echo "<a href=\"" . $clean_uri[0] . "\">" . $clean_name[0] . "</a>" . $wedge; }
echo $clean_content[0];
echo $suffix_sub;

}
}
echo $prefix;
parse_feed($usernames, $limit, $show, $prefix_sub, $wedge, $suffix_sub);
echo $suffix;
?>

08. Display Latest Tweet as an Image

InstantShift - Twitter Hacks For Your WordPress Blog

TwitSig is a twitter signature service provider that allows you to get an auto-updating image that displays your latest Twitter entry. You can use this image as your forum signatures, in WordPress posts, in blog sidebars or may be even in emails.

Go to Twitsig.com and enter your Twitter username. And you are good to go with your Twitsig image displaying your latest tweet. The image is automatically updated when you update your Twitter status. Now you can show your latest tweet using following code wherever you want.

<a href="http://twitter.com/instantshift"><img src="http://twitsig.com/instantshift.jpg"/></a>

09. Detect Visitors From Twitter

InstantShift - Twitter Hacks For Your WordPress Blog

If you have significant visitor base from Twitter then will it not be a great idea to detect Twitter visitors and offer them a warm welcome, remind them that their re-tweets are appreciated. You might also want them to point towards some specific blog posts or some freebies that they might interested in.

For that you can add following code in your single.php file and add your welcome message.

<?php if (strpos("twitter.com",$_SERVER[HTTP_REFERER])==0) {
echo "Welcome, Twitter visitor! If you enjoy this post, don't hesitate to retweet!";
} ?>

10. Your Twitter Feed on a Separate WordPress Page

InstantShift - Twitter Hacks For Your WordPress Blog

You might want to create a separate page on your WordPress blog for displaying your latest tweets and updates. For that Smashing Magazine suggested a solution using “Page template” feature in WordPress. First you will need to create a Twitter page template “twitter-page.php” (you can use different name) to display Twitter feed, paste the following code and add it to your blog. Simple enough, huh!

<?php

/* 
Template Name: Twitter page 
*/

get_header();

include_once(ABSPATH.WPINC.'/rss.php');
ks29so_rss('http://twitter.com/statuses/user_timeline/16906892.rss', 20);

get_sidebar();
get_footer();
?>

Find Something Missing?

Feel free to share any hack that you think would be a great addition in this collection and that has not been listed already.

Like the article? Share it.

LinkedIn Pinterest

156 Comments

  1. Thanks for the list. I’m getting a error with number 6, ‘Display X number of Your Latest Twitter Entries’.
    It says: Parse error: syntax error, unexpected ‘=’ in *file* on line *line*
    The problem goes about this line:
    for ($i = 1; $i < = $amount; $i++) {

  2. I have created a plugin called twounter which displays the total number of followers and has cache support enabled (for sites with large number of visitors otherwise you will burst the api limit of twitter).

    The plugin can be found at http://themesphere.com/twitter-counter-wordpress-plugin.html

  3. Everyone is twittering… Ever wondered how twitter works ? Here is a simple english video explaining it and also shared top twitter tool list. Hey by the way check out the cool twitter dance song video too.. enjoy

    http://askwiki.blogspot.com/2009/05/twitter-explained-in-plain-english.html

    Good Day

  4. For retweeting, I still vote the tweetmeme plugin. Good list here though.

  5. Thanks for the list, very useful for wordpress/twitter fans.

    @WayneSutton on twitter

  6. @Kees, Can you try it again now.

    It’s working on me. Just tested.

  7. I wrote the plugin Tweetly Updater that sends a new Twitter message when you publish a post. It uses bitly for short urls, so you can see the click statistics. See: http://bit.ly/8Rj

  8. Hello, thanks for sharing these twitter hacks :)

    By the way, does anyone know where can I get avatars like the ones in this post at “04. Use Twitter Avatars in Comments” ? Or they are created by their authors?

    Thanks!

  9. Useful list, although there is are WordPress plugins for every feature you mentioned, if you don’t like coding.

    Cheers!

  10. AWESOME list, been looking for some of this functionality and a lot of the plugins just don’t cut it… nice to see most of my needs covered by simple scripts!

  11. Nice collections of tips and tricks, thanks for sharing :)

  12. Cool, very useful post, thanks a lot..

  13. Very helpful post

    Thanks

  14. Yes, most of these can be found as plugins but plugin doesnot offer much customizations if you want to style your tweets.

    These hacks/code is further customizable and you can style these to match your website/blog styles. That is what I like about hacks. Last but not least, you learn new stuff. :)

  15. Great list. Just love the third one. Thanks

  16. @friendlyknoxguy (What I am wondering is how can you integrate Twitter ID in your comments. For example, like your page here when you go to post a comment, it gives Name, E-mail and Web address. How can you add one for Twitter and then have that id linked to their Twitter account? Thanks for your help and great hacks here! I have done a hack for the welcoming Twitter visitors.

  17. Nice list! :)

  18. thanks for this, im going to test out the twitsig now…

  19. i gust want to say some thing “great job”

    Update your Twitter randomly according to your intrest Or, from Rss Feed Or, from your own tweet message list Or, Any combination of the above three http://feedmytwitter.com

  20. Twitsig is a cool service. Very easy to use and lots of exposure. Isn’t it?

    Well, it’s not very hard to develop such a service for yourself, you just need to use latest tweet script we posted and use GD library to create a image for that. Simple enough. :)

  21. Very helpful, i especially liked the Google insights heads up. Not seen it before and I am sure that it will have its uses. Many, many thanks.

  22. Joe,

    I think you have 3 tweets right now. I am sure you can increase tweet count in plugin settings.

  23. I love little snippets like these and personally prefer them over plugins. Keep ’em coming!

  24. Have yet to fully incorporate twitter into my blog at WunderCreative.com. Having some trouble with a wordpress plugin that posts a weekly list of your tweets. Mine seems to make two posts. Any thoughts?

  25. Wow, this is a really awesome set of “hacks”! I got some good ideas from these, especially for my Freaking Bookworm site, which uses a Twitter account as a means for updates. Great post!

  26. Looks like my comment got eaten! :D

    Anyway, this is a great list and I got a lot of ideas from it! Thanks a bunch!

  27. I strongly disagree with the method employed for the hack #2 (and the followings dealing with real time values).

    It’s a real bad habbit: if you call a page 100 times, the TinyURL will be calculated … 100 times. But the URL is unique.

    It’s better to store the value in a custom field.

    So many hacks (in general, not yours especially) are so ugly and bloats WP installs for so tiny details.

  28. Great list! I myself prefer NOT to include my tweets in my professional blog (as sometimes they’re quite bizarre and non-business related) but I can see how that ability would be good in others.

  29. Oncle Tom,

    I’m pretty sure TinyURL will return the same URL every time the tinyurl is requested. I don’t see why it needs to be requested every time the page is loaded.

  30. very interesting an very easy to understand tutorials with images.
    thanks a lot

  31. Tom,

    Nicholi is right. TinyURL returns the same URL every time because of use of their API. The URL generation request is not some random TinyURL function.

    TinyURL API make sure that only one URL has to be generated for a particular page regardless of how many times your reload your page.

    We are also using same API for twitter just below author info (in this post). Please check and try it yourself.

  32. Hi there! This is an awesome page, and I want to really thank you for providing this code, however, there seemed to be a problem with your “07. Display Tweets From Multiple Users”. When I entered in two different Twitter usernames to test out the program, it only returned the first one, in terms of Twitter feeds. I’m thinking it has something to do with these lines:

    $usernames = str_replace(” “, “+OR+from%3A”, $usernames);
    $feed = “http://search.twitter.com/search.atom?q=from%3A” . $usernames . “&rpp=” . $limit;

    and I am trying to debug this for you, but just wondering if anyone else got this same problem, and what your thoughts were on how to fix it?

    Thanks so much again, and keep up the great work!

    Sincerely,
    – Kevin Pajak, Web/Graphic Designer
    http://www.twitter.com/kevinpajak

  33. Kevin,

    I tried the code and it works. It shows the last 5 total from the usernames. I suspect the second username you are using hasn’t been updated since before the 5th tweet of the first account?

    Go to search.twitter.com and search for (using your own usernames) “from:YourFirstUsername OR from:YourSecondUsername” and see what the first 5 tweets are. Are those the 5 tweets you see when you use the code above? If so, it’s working.

  34. Nicholi, you know you are absolutely right, I noticed that in a test too last night. I think the thing that threw me off before was that I was thinking this app would produce the last 5 (“x”) posts from EACH of the Twitter users you specify, but in fact it seems to list the last x MOST RECENT feeds, from any of the users you specify (just as you said). So what I want to do next is make it show last X no. of tweets from EACH OF THE Twitter users. I will work on that.

    Also, one big thing though, the app does display the hyperlinks correctly for the USER NAMES, but for LINKS IN THE ACTUAL FEED ITEMS, it is printing out the <A HREF.. tags as text.

    Ex: Pete Cashmore 7 Technologies Shaping the Future of Social Media – http://bit.ly/jCY00
    The HTML code is rendering as:
    Pete Cashmore 7 Technologies Shaping the Future of Social Media – <a href=”http://bit.ly/jCY00″>http://bit.ly/jCY00</a&gt;

    Something about the original code I think was maybe done incorrectly, but I’m trying to figure that out too.

    And a follow-up note: I plan on developing some code that will allow the user to enter in Twitter name(s), along with no. of tweets desired (like in a form or input boxes), and display that back for the user as well! If anybody has any comments on that, please feel free to let me know!

    Thanks a lot for the comment though, appreciate, and still I think this is a fantastic page/code, that is great for us developers who use Twitter! Thanks to the author for posting it up, and keep up the great work everybody…

    – Kevin

  35. Kevin,
    To fix the links you can add
    $clean_content[0] = str_replace(“<“, “”, $clean_content[0]);

  36. Nicholi is right, tweets are in order of posted time. Please use larger number for total tweets and you will see the difference.

    I also checked code and it’s working but as Nicholi explain, there might be some issues with chars.

    Thanks Nicholi for helping him :) Really appreciated.

  37. Kevin,

    If it still does not work, please post here. I will send you working php file attached with email. ;)

  38. I just found this article, what a great start for me, as I am just getting to grips with twitter and integrating it into my site as a whole.

    Will have to put some of these into my site as soon as I get a chance!

  39. Hey Nicholi and Daniel, thanks a lot for your help, but I did try Nicholi’s fix suggestion, and it still didn’t seem to work. You see, what is happening is the links (“ render fine (i.e. linkable) for the Twitter user name, but for the list item entries that have links, the left brackets (“”) in the HTML are listed as “>”. So basically what it’s doing is rendering all links in the item entries just as text (I’ll try to demonstrate: RT @creattica is what is outputted on the page, rather than the links being linkable).

    Anyway, I will keep working to try to figure this out, and your help would be much appreciated too. Thanks so much! (And Daniel, sure, please feel free to email the code too if you like at: kevin@kevinpajak.com) Thanks a lot!

  40. Actually, I thought it would be even better to include a link to show you exactly how the feed items are rendering:

    http://www.kevinpajak.com/mycustomtweetfeeds.php

    Thanks again for your help and suggestions guys.

  41. Kevin,

    I’m sorry, the comments ate some of the code I posted. :)

    Take a look at the code here. http://falith.com/wp-content/uploads/multitweets.phps

    I commented the two lines that I added to make the links work. Hope that helps.

  42. Nicholi, you rock man! That did the job! Thank you so much! As soon as I saw those lines of code, I thought it would work. (Seems the trick, exactly as you have done here, is forcing the program to replace the ” & lt; ” and “& gt;” with the left and right brackets, and also, I think it was essential that you put it in the for loop, before the “echo $clean_content[0];”. Great job!

    .Now I’m working on extending it a bit further to replace stuff like double quotes (“) – which the code currently is displaying as like, for example: I like this article, & quot ; What the hell am I doing?, & quot ; instead of I like this article, “What the hell am I doing?” but I will solve that.

    This page is fantastic as a possible base for so many things!

    I will be sure and post some stuff here after I make some customizations to it later. Thanks again you guys, great stuff. :-)

  43. Hey guys! I got two things for you that I developed. First one is a resolution to that pesky double-quotes display problem with the feed item content (as well as the left and right arrow characters, in addition to the arrows used in A HREF tags). Here’s the fix, just add this code into what Nicholi posted last time:

            // Make the links clickable
            $clean_content[0] = str_replace("<", "", $clean_content[0]);
            $clean_content[0] = str_replace("&quot;", """, $clean_content[0]);
            $clean_content[0] = str_replace("&lt", "", $clean_content[0]);
    	echo $clean_content[0];
            echo $suffix_sub;
    

    Also, I set up a little app that will allow the user to enter in the Twitter name and desired number of most recent posts from that user, I will post the code for that next time. Seems though that this is restricted (from Twitter itself looks like) to posts only from the last 1-2 weeks. (This is one of those things about Twitter I have read complaints about: how they only turn up results within a 1-2 week time period in their search engine). Oh well, we’ll try to work with it I guess

  44. Ah, looks like it ate some of the code. Well anyway, here is the code to replace the double quotes back (“). I am adding spacing in to allow it to render here, just make sure you type ALL CHARACTERS between the ” and ” marks with NO SPACES, I’m only adding in the extra spaces here to get the code to render properly:

    $clean_content[0] = str_replace(” & amp ; quot ; “, ” & quot ; “, $clean_content[0]);

  45. Does anyone know of a plugin that will publish your Twitter updates once per day as a blog post, rather than a widget?

  46. Thank you to share

  47. nice post.. thanks.

  48. Awesome post. Definitely going in my tutorial bookmarks folder. I have a quick question however.

    I’m using: [ 01. Create a “Twitter This” Button for WordPress Posts ] and I’ve run into a problem.

    It seems to break whenever I have a post that includes a hashtag (#). For example, if the post ends with “#s$1” the button sends me to http://twitter.com/s$1, which isn’t anything at all, just an error page. Any suggestions on how to fix this?

  49. Ha, I just figured out how to fix it.

    For those of you who have this problem, I used:
    str_replace(“#”,”%23″,$variable);
    which replaces all pound signs with that lovely encode.

  50. this is super tools i am looking for! thanks!

  51. Great article, though you should have given credits to the original sources. For example, the “03. Displaying Total Number Twitter Followers on WordPress” came from my blog WpRecipes.com. Some other hacks comes from a post I wrote a while ago at Smashing Magazine.

    There’s nothing bad to republish content from other blogs, but you should definitely include a link to the source.

  52. Hi!

    I think it would be sweet if there was a hack/plugin for wordpress blogs where at the bottom of each article, you could include a twitter feed around a specific company, such as ‘Kiva’ or a hashtag #microfinance. I see it similar to the TechCrunch company templates at the bottom of a post, but include the latest 5 tweets.

    I know there are apps like monitter and open brands, but I haven’t found exactly what I’m looking for. I think an app like this would be extremely helpful for all bloggers and bring the ‘stream’ into every story. Not simply bringing the story into the stream.

    If anyone knows of such an app, please email me at erik at socialearth dot org.
    Thanks!

  53. Holy good advice…

    I will b e re-reading this again, and again, and again….

  54. Very Helpful

  55. Pretty useful and original hacks, specially the twitter avatar and tweets as image is really awesome.

  56. I tried the script to “Display Tweets From Multiple Users” but it doesn’t show up anything. I get a blank page without any error. I put the usernames separated by space as directed.

    please help

  57. Display X number of your latest twitter entries is not working either.

  58. Thanks! Works great for me!

  59. Hi guys,

    Nicholi has posted a fix for “Display Tweets From Multiple Users” to render the links correctly, but the link http://falith.com/wp-content/uploads/multitweets.phps doesn’t work anymore.

    Could anyone post the code, please?

  60. OK Nicholi, Norm and eveyone! Finally, here is the code for my enhanced Twitter Hack #7 (from above) : “Display Tweets From Multiple Users”.

    VIEW THE SOURCE CODE ON THIS PAGE:
    http://www.kevinpajak.com/blog/code-repository/customized-tweet-feed-display/

    *NOTE: I’m still working on enhancing the app further, and I will likely add some notes for developers on this page as well! Please everyone share your thoughts, code, your intended/possible uses for this code, and other feedback. Thanks, and happy coding everybody!

  61. Yeah, thanks man! :)

  62. Hey,

    Great hacks for twitter. I have the #6 hack working fine for my site, however, I want to have an alternate color for every other twitter that gets posted. I can read and understand most php, however I am not sure how to use the for loop in order to produce this effect properly. My idea was to create a $tweetprefixalt = etc. and use the for loop to alternate between that and the $tweetprefix, however I’m not quite sure how to do it properly.

    Any help would be great.

    http://www.sneterz.com is my site, I have the code running on the sidebar as well as an example of what I want it to look like.

  63. How about our “Tweet Us at wittysparks custom Twitter Widget” – http://www.wittysparks.com/2009/08/24/tweet-us-at-wittysparks-custom-twitter-widget/

  64. Twitter now worth 1 billion yet its always to busy to fulfill your request whats going on >?

    great post dude implemented a few on my modified car forums / blog / club today after reading this

  65. I’m looking for a simple WP Twitter hack. Would anyone be able to take a look at http://www.valleyprblog.com and tell me what they’re using for their Tweetroll at the bottom of their sidebar? I just want a simple Twitter sidebar plug-in that just lets me link to 5-10 of my favorite Tweeps that I’m following. That’s all I want.

    Everything I’ve found goes beyond that, and shows who’s following me, what I just tweeted, shows icons, etc…overkill. I just want text links, and something that I could easily edit from the wp-admin panel to switch out who I’m following. Thank you! – Jenna

  66. Nice write up. This will definitely become handy when my site gets more users.

  67. Edit to the post above, it doesn’t show the link like that it just shows the etc…

  68. I tried all the fixes that were mentioned for #7 (Display Tweets From Multiple Users) but I’m still running into problems with the links not showing correctly. This is what shows:

    Shane Carwin: @switchbladejake He already got beat up once so 1 new fight and a rematch.

  69. Very helpful and informative. I will be implementing this into a few sites of my own. Thanks for the time put into this.

  70. I tried using number 7 to display my twitter feed.
    I changed the ‘limit’ to 50, but it still only shows 5.
    Yes I have more than 5 tweets.
    Could there be some mysterious caching going on somewhere?

  71. Nice One……

  72. Thankyou guys.
    I have the same issue of and i resolve that after reading the comments.

    @Andress
    Why don’t you change the code in the post with the error free code for displaying tweets.

  73. Very helpful and informative. I will be implementing this into a few sites of my own. Thanks for the time put into this.

  74. Good list here though.

  75. Good list here though.

  76. WordPress Blog Services – How To Display Your Latest Twitter Entries on WordPress

  77. Does anyone know a way to inculde twitter tweets into my blog posts?

    By this i mean my page would show in order:
    Blog post
    Blog post
    Twitter tweet
    Twitter tweet
    Twitter tweet
    blog post
    Twitter tweet
    etc

  78. thx nice list

  79. thxxxxxx

  80. thx for sharing

  81. thx

  82. Twitter is not bigger than Facebook. At this point Facebook is now above Yahoo in traffic, and the #2 visited site (after Google). Twitter is not even in the top 10.

  83. Thank you! I just went through several Twitter widgets and I didn’t like them for a variety of reasons. With this one, I can make it look how I want. As a programmer, I’m not scared to add it right into the PHP.

  84. Hi Great tips thanks!

    I’m having trouble with 7 – Multiple tweets

    It’s showing the links rather than linking to them you can see this on http://www.arontribe.com

    Could you please let me know how to fix this? The previous post about this leads to a dead link

    Thanks

  85. Hi all…

    With all thats been posted on this page & with comments the below code is now displaying the most recent tweet with CLICKABLE links…

    HOWEVER – (cos my php skills are only basic level) could someone see why the loop is not stopping?

    -is printing the same tweet …

    < ?php
    $usernames = "USERNAME"; // Pull from accounts, separated by a space
    
    $limit = "1"; // Number of tweets to pull in, total.
    $show = 0; // Show username? 0 = No, 1 = Yes.
    
    $prefix = ""; // This comes before the entire block of tweets.
    $prefix_sub = ""; // This comes before each tweet on the feed.
    $wedge = ""; // This comes after the username but before the tweet content.
    $suffix_sub = ""; // This comes after each tweet on the feed.
    $suffix = ""; // This comes after the entire block of tweets.
    
    function parse_feed($usernames, $limit, $show, $prefix_sub, $wedge, $suffix_sub) {
    
    $usernames = str_replace(" ", "+OR+from%3A", $usernames);
    $feed = "http://search.twitter.com/search.atom?q=from%3A" . $usernames . "&rpp=" . $limit;
    $feed = file_get_contents($feed);
    $feed = str_replace("&", "&", $feed);
    $feed = str_replace("<", "", ">", $feed);
    $clean = explode("", $feed);
    $amount = count($clean) - 1;
    
    
    for ($i = 1; $i < = $amount; $i++) {
    
    $entry_close = explode("", $clean[$i]);
    $clean_content_1 = explode("", $entry_close[0]);
    $clean_content = explode("", $clean_content_1[1]);
    $clean_name_2 = explode("", $entry_close[0]);
    $clean_name_1 = explode("(", $clean_name_2[1]);
    $clean_name = explode(")", $clean_name_1[1]);
    $clean_uri_1 = explode("", $entry_close[0]);
    $clean_uri = explode("", $clean_uri_1[1]);
    
    $clean_content[0] = str_replace("<", "", $clean_content[0]);
    $clean_content[0] = str_replace(""", """, $clean_content[0]);
    $clean_content[0] = str_replace("&lt", "", $clean_content[0]);
    $clean_content[0] = str_replace(""", "\"", $clean_content[0]);
    echo $clean_content[0];
    echo $suffix_sub;
    
    echo $prefix_sub;
    if ($show == 1) { echo "" . $clean_name[0] . "" . $wedge; }
    echo $clean_content[0];
    echo $suffix_sub;
    
    }
    }
    echo $prefix;
    parse_feed($usernames, $limit, $show, $prefix_sub, $wedge, $suffix_sub);
    echo $suffix;
    ?>
    
  86. THIS CODE WORKS – displays the latest tweets and fixes the clickable links! :-)

    <?php  
    $username = "macslondon"; // Your twitter username.  
    $prefix = ""; // Prefix - some text you want displayed before your latest tweet.  
    $suffix = ""; // Suffix - some text you want display after your latest tweet.  
    $feed = "http://search.twitter.com/search.atom?q=from:" . $username . "&rpp=1";  
    
    function parse_feed($feed) {  
    $stepOne = explode("", $feed);  
    $stepTwo = explode("", $stepOne[1]);  
    $tweet = $stepTwo[0];  
    $tweet = str_replace("<", "", $tweet);  
    $tweet = str_replace("<", "", $tweet);
    $tweet = str_replace("&quot;", """, $tweet);
    $tweet = str_replace("&lt", "", $tweet);
    $tweet = str_replace(""", "\"", $tweet);
    return $tweet;  
    }  
    
    $twitterFeed = file_get_contents($feed);  
    echo stripslashes($prefix) . parse_feed($twitterFeed) . stripslashes($suffix);  
    ?>  
    
    
    
  87. I was looking for a twitter plugins for my blog and i found your blog thro Google. Loved your post. Thanks for sharing the knowledge.

  88. hi

    i wanna know how to promote my site in a well systamatic manner .
    thnks for ur information

    lara
    http://www.witterthemes.com

  89. Thank you for this info, I have tried it on my blog. It looks nice.

  90. Thanks for the multi user Tweeter feed code.

  91. ı will try it, thanks for sharing

  92. it looks very nice, thanks..

  93. Was wondering if anyone else is experience a problem with words such as I’m? On tweets where I’ve used anything with a ‘ the code spits out I'm. Any help is appreciated

  94. Ok my last post didn’t work LOL! It’s spitting out I I & apos ; m (minus the spaces).

  95. Great list. Just love the third one. Thanks

  96. I agree with Oncle Tom… since TinyURL will return the same tiny url every time (which is what you all keep saying, missing his point), then why request it from their servers every time the page loads? Why not request it once then store it in a custom field? Then your server doesn’t have to run off to theirs EVERY time a page loads.

  97. veryThnks

  98. thank you good

  99. This is some really cool stuff. Thank you for sharing!

  100. This fix the links of 05.Display Your Most Rcent Tweet

    <?php
    $username = "username"; // Your twitter username.
    $prefix = ""; // Prefix - some text you want displayed before your latest tweet.
    $suffix = ""; // Suffix - some text you want display after your latest tweet.
    $feed = "http://search.twitter.com/search.atom?q=from:" . $username . "&rpp=1";
    
    function parse_feed($feed) {
    $stepOne = explode("", $feed);
    $stepTwo = explode("", $stepOne[1]);
    $tweet = $stepTwo[0];
    $tweet = str_replace("<", "", $tweet);
    $tweet = str_replace(""", "", $tweet);
    return $tweet;
    }
    
    $twitterFeed = file_get_contents($feed);
    echo stripslashes($prefix) . parse_feed($twitterFeed) . stripslashes($suffix);
    ?>
  101. can someone paste in the code that is needed to fix the broken links from #6? Nicholi had linked to the code but that link is broken. thanks.

  102. Nice list, i gave a try to the multiple user feed. In order to render the html links properly this should be added:

    $clean_content[0]=htmlspecialchars_decode($clean_content[0]);

  103. TwitSig twitter signature is one of the best twitter tools I have come across, this allows me to add my signature with twitter, Thanks you very much for sharing these tips all in one place to find. :-)

  104. good hacks ……… i will surely use these hacks on my blog

  105. very good hacks really impressive

  106. Wow, some AWESOME twitter hacks, thanks a lot!

  107. Very helpful. Thanks a lot. !

  108. Such a great list for Twitter users, I’m sure to use a few on them, thanks for including the tweet this feature, I think it would work well on my blog.

  109. thanks for admin thanks..

  110. I tried inserting the code of ’07. Display Tweets From Multiple Users’ into a page but the page shows the code, not the twitter messages. Any ideas? thanks in advance.

  111. it’s too important

  112. thank you good

  113. Thanks for the list. Tried the code and it worked!

  114. I really like the twitter avatar thing. I might hook that up on my site tonight!

  115. Fantastic advice! I will defiantly be trying a few of these techniques. Thanks!

  116. Thanks for sharing ur ideas…..

  117. hey hi, i found your info very useful,
    i have a mba university and courses website, i want to display all the latest tweets of corresponding universities after my post ends,
    which code to use?
    please suggest me???

  118. hey nice piece of info,
    i am using “Display X Number of Your Latest Twitter Entries” this code,
    in this i don’t want the tiny url, how can i avoid that, instead that can i get that tweet url of twitter ID???

  119. Thanks for awesome hacks. Will try to implement some of them.

  120. wow.. finally was able to crack it :)
    but how do i strip the web link?

  121. Question for: 07. Display Tweets From Multiple Users

    Is it possible to add the “tweet time” to this code?
    Ex. 43 minutes ago

    Thanks.

  122. wow the post is really amazing the content of the blog is nice one..

  123. Cool!! This post is very impressive. It’s very useful for wordpress as well as for twitter.

  124. i need a code where my wp blog automatically post to twitter.

  125. I’m using ‘Display Tweets From Multiple Users’ now for my site for two Twitter accounts and it’s working great but….

    Is there a way to hide the @replies from the list?

    It should be the finishing touch for this script :)

  126. Keep the hacks coming.

  127. I’ve been using twitter but I am not totally known about the techniques on how to used it. The only thing that I know about twitter is just only posting. I’m looking forward to learned more on it. I hope someone can help me on how to use twitter.

  128. Twitter has around 200 million registered users while Facebook has over 500 million. Though Facebook has a wider audience it would be a loss if one does not use Twitter.

  129. Thanks for the awesome code. I was searching it on Google from last 2-3 months. You make my task easy, actually I’m using twitter and want to know the status of it on my blog. Thanks a lot for sharing with me.

  130. What I am looking to do is similar. I am looking to have a static page as well as the blog appear on the main page of my wordpress site. Right now going to the settings section will only allow me to do one or the other. any feedback would be appreciated.

  131. bookmarked this for my motor blog

  132. I’m relatively new to Twitter so I’m still learning about all it has to offer. I thought this was a really helpful post. I had never heard about “TwitSig” until now, I’m very keen to try it out!

  133. wow the post is really amazing the content of the blog is nice one..

  134. Great share, this il all very new to me because i´m a noob in WordPress, but your codes seem too easy to use. Let me try it and I will give some feed back soon.

  135. Great list! I’m relatively new to Twitter and I found this post really helpful. Thanks for sharing!

  136. Nice collections of tips and tricks

  137. This is my message. AHTUNG!

  138. oh my god…. this is amazing!

  139. Yeah, it happens sometimes … Nothing special.

  140. Nice post.Thank you for taking the time to publish this information very useful!I’m still waiting for some interesting thoughts from your side in your next post thanks.

  141. I have been using an app called AutoTweeterPro for sometime. It’s a small & very easy-to-use software, which tweets from my computer. I am using unlimited trial version,which is as good as free. Hope you will find this tip useful -http://bit.ly/autotweeterPro1

  142. Thank for this post.That was really what ı was looking for and its completely works..

  143. suggested a solution using “Page template” feature in WordPress. First you will need to create a Twitter page template “twitter-page.php” (you can use different name) to display Twitter feed, paste the following code and add it to your blog. Simple enough, huh!

  144. A blog has grown to essentially cover commentary, opinion or observations posted to a Web site on a regular basis. It’s a pulpit from which anyone can share their views with the world. Bloggers (the people that write blogs) include a number of traditional columnists, analysts and pundits. In their cases, blogs let them extend their expertise and audience beyond the confines of the printed, broadcast or packaged publication.

  145. Wow thanks so much for this article, very useful!

  146. Thanks for all the warm advice you’ve given it has me heated up to get tweeting and twitter on my blog more integrated! Thank you thank you thank you!

  147. Great Tips. I am using
    10. Your Twitter Feed on a Separate WordPress Page

    method. but problem is that tweets does not looks good, Please tell me how can i add some styling, i want to add some padding, color and a background image for tweet page.

  148. This helps me a lot when I integrate my WordPress and Twitter accounts. It was easy for me to install a Twitter widget in my blog. Thanks for the heads up.

  149. I have much to learn more from you, this is very interesting information to be learned. Thank you!

  150. Thank you for the info on this topic. I have build a few wordpress website and twitter always seems to cause a few problems. This will help for sure.

  151. Great post, we used wordpress to build our website and twitter was a bit tricky but we have it now. Thank you

  152. Thank you for the useful information on this topic. I look forward to hearing more!

  153. Haha! This as too much fun. I’ll try it now!

    Regards and looking forward to more posts,
    Grace

  154. Wow. Great tutorial.

  155. Hello.. very nice topic.. I have enjoyed a lot also learn some new from your site.. I hope you will carry on and give me a space to connect with you for a long.. Thank you very much .. I will read it again .. Thank you

Leave a Comment Yourself

Your email address will not be published. Required fields are marked *