15 Useful Twitter Hacks and Plug-Ins For WordPress

Advertisement

Since its launch in 2006, Twitter has grown to create what most people would call a social media revolution. By the very nature of the short messages it hosts, Twitter is a wonderful marketing and promotion tool that no serious blogger can ignore.

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

You may want to take a look at the following related posts:

1. WordPress Hacks For Twitter Link

WordPress plug-ins are good, but if you have 50 different plug-ins active on your blog, you should obviously expect longer loading times and even some inconvenience. This is why we love hacks! First let’s dive deep into WordPress and see what hacks can do to enhance our blogging experience. In the second part of this article, we will also show you some useful Twitter plug-ins for your WordPress blog.

Automatically create TinyUrls for your blog posts Link

Because of the restriction on character numbers in Twitter, you have to use a URL shortener when tweeting URLs. So, to help your readers tweet about your posts, you should definitely provide short URLs for all of your posts.

Here’s how to automate that task:

Open your functions.php file and paste the following code:

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

Once done, paste this in your single.php file, within the loop:

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

To see this in action, visit my website, WpVote3, and look at any post.

Source: How to: Automatically provide TinyUrls for your WordPress blog posts4

Display your latest tweet without a plug-in Link

If people like your blog, they would probably also enjoy your tweets. Displaying your latest tweets on your WordPress blog is a good way to gain new subscribers. A plug-in can do that, but for such a simple task, I prefer a hack. This one grabs your latest tweet and displays it on your blog.

This ready-to-use code can be pasted anywhere in your theme files. Just don’t forget to change the value of the $username on line 4. The $prefix and $suffix variable can be used to insert a title, and the div element can be used for further CSS styling.

<?php

// Your twitter username.
$username = "TwitterUsername";

// Prefix - some text you want displayed before your latest tweet.
// (HTML is OK, but be sure to escape quotes with backslashes: for example href="link.html")
$prefix = "<h2>My last Tweet</h2>";

// Suffix - some text you want display after your latest tweet. (Same rules as the prefix.)
$suffix = "";

$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);
?>

Save the file, and your latest tweet is displayed on your blog. Nice, huh?

Sources:

Display your latest tweet as an image Link

Because of Twitter’s success, a lot of third-parties have started promoting additional Twitter services. TwitSig7 is one of them. This website is very ugly but also very cool because it allows you to get an auto-updating image that displays your latest Twitter entry.

While using this image as a signature in forums would be good enough, integrating it in your WordPress blog, under your posts for example, would also be great.

  1. Go to Twitsig.com8. You don’t have to register: very nice!
  2. Simply enter your Twitter username in the text field.
  3. And your Twitter image is ready, displaying your latest tweet. The image is automatically updated when you update your Twitter status.
  4. Open any of your WordPress theme files and paste the following code (make sure to replace my username with yours!):
    <a href="http://twitter.com/catswhocode"><img src="http://twitsig.com/catswhocode.jpg"></a>

Create a “Tweet this” button Link

Twitter is definitely a great way to gain exposure on the Web. This is why I created a fancy “Send to Twitter” button and implemented it on my blogs (see links at the bottom of the article). Go here9 if you’d like to see this hack in action.

  1. Open the single.php file in your theme.
  2. Paste the following code where you’d like your Twitter button to appear:
    <a href="http://twitter.com/home?status=Currently reading <?php the_permalink(); ?>" title="Click to send this page to Twitter!" target="_blank"><img src="send-to-twitter.png" alt="" /></a>

Some time ago, in my “Mastering WordPress shortcodes10” article here on Smashing Magazine, I showed you how to create a “Send to Twitter” WordPress shortcode. I also wrote an article on Pro Blog Design about creating a “Send to Twitter” WordPress widget. You can read that tutorial here11!

Detect a visitor from Twitter Link

Visitors coming to my blogs from Twitter now represent something like 10% of all my traffic, which is quite a lot. Because many Twitter users re-tweet blog posts that they like, it may be a very good idea to detect Twitter visitors, welcome them and, of course, remind them that their re-tweets are appreciated.

To do this, open your single.php file and paste these lines where you’d like your “Welcome Twitter user” message to be displayed.

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

This code will detect readers coming from Twitter and display the message only to them.

Create a Twitter page on your WordPress blog Link

We already showed you how to display your latest tweet on your blog, in your sidebar for example. Another good way to introduce readers to your Twitter updates is to create a dedicated page for displaying your tweets, using the powerful “Page template” WordPress option.

To perform this hack, you need to know how to create and use page templates. If you’re not familiar with this, this article12 will tell you all you need to know.

Here’s the code to create a Twitter page template. Paste it in a new file, name the file something like twitter-page.php, for example, and then add it to your blog.

<?php

/*
Template Name: Twitter page
*/

get_header();

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

get_sidebar();
get_footer();
?>

This code uses the wp_rss() function from WordPress core, which is an RSS reader. In the first argument I pass my Twitter RSS feed, and in the second argument I determine the number of entries to display.

Using Twitter avatars in comments without plug-ins Link

I was pretty interested in the Twittar plug-in when it was first released and decided to look at the source to see how it works. Being a die-hard WordPress hack fanatic, I decided to create a hack using the Twittar code.

Follow these simple instructions to use Twitter avatars in your blog comments without a plug-in:

  1. The first thing is to get the functions file here13.
  2. Once you have it, unzip the archive and open the twittar.php file. Select all of its contents and paste it in the functions.php file in your theme.
  3. Now, open your comments.php file and find the comments loop. Then, just paste the following line where you’d like the Twitter avatars to be displayed:
    <?php twittar('45', 'default.png', '#e9e9e9', 'twitavatars', 1, 'G'); ?>

Source: How to: Use Twitter avatars in comments14

2. WordPress Plug-Ins For Twitter Link

Twitter Updater15
Are you using Twitter to notify readers about your new blog posts, or even old ones that you’ve updated? If so, then Twitter Updated is definitely something to consider. The plug-in automatically sends an update status request to Twitter when you create or modify a post. Text is customizable, and the plug-in provides many options.

Twit this16
The Twit This plug-in makes it easy for readers to tweet about your blog posts by creating a “Share on Twitter” link on your blog. When someone clicks on it, your blog post’s URL is automatically sent to Twitter, and the visitor can enters a description before sending the tweet to his or her friends.

Twit it up17
Twit it up is a simple AJAX-powered WordPress plug-in that basically does the same thing as Twit this: allows readers to tweet one of your posts directly from your blog by clicking a simple link.

Twit-Twoo18
Twit-Twoo is a very useful for bloggers because it allows you to tweet friends directly from your WordPress dashboard. Particularly great if you spend a lot of time on your WordPress dashboard!

Twitter Tools19
Twitter Tools, created by Alex King, is one of the most popular Twitter plug-ins for WordPress. It completely integrates Twitter in your WordPress blog, allowing you to archive your tweets, create a blog post from each of your tweets and post tweets from your admin dashboard or sidebar. It also allows you to create a daily digest of tweets; very nice if you tweet a lot!

Twittar20
Twittar was released here on Smashing Magazine back in January21. Remember it? This plug-in integrates Twitter avatars in the comment template of your WordPress blog. Definitely a plug-in to consider if you and your readership often use Twitter! And don’t worry if any of your readers don’t use Twitter (yet), Twittar automatically displays gravatars if no Twitter avatar is available.

Tweetbacks22
Since its release only one month ago, the Tweetbacks plug-in has created a mini-revolution in the blogging world. While your WordPress blog can automatically notify you when bloggers discuss your posts on their own blogs, via Trackbacks, it can’t notify you when people discuss your posts on Twitter. That’s why Tweetbacks is so great: it automatically imports tweets about your posts and lets you display them either as comments or separately.

You may want to take a look at the following related posts:

(al)

Footnotes Link

  1. 1 http://www.smashingmagazine.com/2009/03/02/twitter-web-designer-and-developer-toolbox-api-and-tutorials/
  2. 2 http://www.smashingmagazine.com/2009/02/03/8-useful-tips-to-become-successul-with-twitter/
  3. 3 http://wpvote.com
  4. 4 http://www.wprecipes.com/how-to-automatically-provide-tinyurls-for-your-wordpress-blog-posts
  5. 5 http://www.wprecipes.com/how-to-display-your-latest-twitter-entry-on-your-wp-blog
  6. 6 http://scriptplayground.com/tutorials/php/Latest-Twitter-Update-With-PHP/
  7. 7 http://www.twitsig.com
  8. 8 http://www.twitsig.com
  9. 9 http://www.psdrecipes.com/freebies-1-create-a-book-cover-with-a-photoshop-script
  10. 10 http://www.smashingmagazine.com/2009/02/02/mastering-wordpress-shortcodes/
  11. 11 http://www.problogdesign.com/wordpress/how-to-create-your-own-twitter-widget/
  12. 12 http://www.wprecipes.com/how-to-create-and-use-wordpress-page-templates
  13. 13 http://www.smashingmagazine.com/2009/01/08/twitter-avatars-in-comments-wordpress-plugin/
  14. 14 http://www.wprecipes.com/ho-to-use-twitter-avatars-in-comments
  15. 15 http://blog.victoriac.net/blog/twitter-updater
  16. 16 http://twitthis.com/
  17. 17 http://www.jonbergan.com/2009/01/07/introducing-twit-it-up/
  18. 18 http://deanjrobinson.com/projects/twitt-twoo/
  19. 19 http://alexking.org/projects/wordpress/readme?project=twitter-tools
  20. 20 http://www.smashingmagazine.com/2009/01/08/twitter-avatars-in-comments-wordpress-plugin/
  21. 21 http://www.smashingmagazine.com/2009/01/08/twitter-avatars-in-comments-wordpress-plugin/
  22. 22 http://www.smashingmagazine.com/2009/01/09/tweetbacks-plugin-for-wordpress/
  23. 23 http://www.smashingmagazine.com/2009/03/02/twitter-web-designer-and-developer-toolbox-api-and-tutorials/
  24. 24 http://www.smashingmagazine.com/2009/02/03/8-useful-tips-to-become-successul-with-twitter/

↑ Back to top Tweet itShare on Facebook

This guest post was written by Jean-Baptiste Jung, a 28-year-old blogger from Belgium, who blogs about Web Development on Cats Who Code, about WordPress at WpRecipes and about blogging on Cats Who Blog . You can stay in touch with Jean by following him on Twitter.

Advertisement
  1. 1

    Very nice post, thanks alot,

    0
  2. 2

    very useful discussion, thanks for the walkthrough XD

    0
  3. 3

    Excellent article, I have just integrated twitter into my blog but will go back and check these out.

    0
  4. 4

    Great post. Very helpful as I am new to the twitter world and still figuring everything out. I really like the tweetbacks plugin.

    But, boy some of those logos are horrific!

    0
  5. 5

    Ahah Cool !.
    Thinking to implement one on my blog.. :P

    0
  6. 6

    Nice Article Jean….!!

    0
  7. 7

    Nice article – Some useful code snippets for future use. Thx.

    TwitMe is another option for integrating Twitter directly into the dashboard.

    0
  8. 8

    Exactly what I was looking for!!! tweeting this! :)

    0
  9. 9

    Nice list. This is what I’m looking for.

    0
  10. 10

    You missed http://tweetmeme.com/button.php which basically works like digg, but for twitter.

    0
  11. 11

    Tweeting rules! Nice list.

    0
  12. 12

    Great list!
    I had’nt thought of most of the functionnalities presented here! The web is full of wonderful people!

    0
  13. 13

    Was never a huge fan of Twitter… but I think this article has changed my mind. Thanks!

    Sinoun

    0
  14. 14

    Long but interesting article. I’m not a Twitter fan but never know ;)

    0
  15. 15

    Thanks a million for the Twitter tips! I’ve tried a few Twitter plugs and ended up creating a separate page and dropping Twitter’s code into it. The tips you provided will allow me to do exactly what I want without having to send users to a secondary page, THANK YOU!!!

    Peter Vatistas

    0
  16. 16

    Go to Twisig.com. You don’t have to register: very nice!

    i think you must correct that text and its link,
    thank for the info :)

    0
  17. 17

    sorry, i mean this line :)
    Go to Twisig.com. You don’t have to register: very nice!

    0
  18. 18

    I use TwitIMG.com for my forum images, just put in your twitter name, up pops an image.

    0
  19. 19

    Hey Jbj you’re in great shape right now ! Thanks a lot for your Twitter hacks, I’ll try to do these on my blog ! ;)

    0
  20. 20

    Thanks, going to implement some at my blog!

    0
  21. 21

    Very cool list!!

    0
  22. 22

    Cool, I’ll have to incorporate some of these in my open source Twitter Inspired WordPress theme:
    Twordder

    0
  23. 23

    I tried implementing the “Display your latest tweet without a plug-in”, but I keep getting errors. I pasted it on the sidebar.php file if that helps.

    Thanks!

    0
  24. 24

    Thanks for the great post! Twitter is just taking over now.

    0
  25. 25

    Cool. I also appreciated the link to WPRecipes and the page creation tutorial.

    0
  26. 26

    Good stuff here – i will have to play with some of those hacks.

    i have also been using Twitter tools for well over a year now. It does a lot of great things, though I had to stop the daily digests as it was creating some empty blogging for me when I would tweet regularly but post only once in a while.

    OTOH, it has been interesting to go back and read those same Twitter digest entries from last year.

    Good stuff!
    James

    0
  27. 27

    Incredible the amount of PR Twitter’s been getting lately. First, Capitol Hill, then the Daily Show, now Smashing Mag. I am extremely excited to see what the world can do with Twitter technology!

    0
  28. 28

    Jean-Baptiste Jung

    March 4, 2009 2:22 pm

    Thanks to everyone for the great comments, glad you enjoyed the post!
    Don’t forget to digg it if you like.

    0
  29. 29

    There is much communication to gain by integrating twitter with traditional blogs!!

    I’m working on another twitterplugin for wordpress right now – similar to tweetbacks but with a twist :-). I have already made a twitter-plugin for wordpress (CommentTweets) for sending notifications (@replies) to your twitter-account when somebody has continued the conversation on a blog post you have commented on; http://wordpress.org/extend/plugins/commenttweets

    0
  30. 30

    The Virtual Consulting Firm

    March 4, 2009 3:21 pm

    Great Article, Tips and Tools, Jean-Baptiste! :)

    Thank you for compiling and sharing all of this information with all of us! :)

    0
  31. 31

    Twitter, the tool for bird brained twits that just *have* to share their vacuity with everyone.

    0
  32. 32

    Wow! Thanks for showcasing Twit It Up in your list of Twitter Plugins. Hope you guys like it! Great roundup of hacks/plugins also. Keep up the fantastic work!

    Rgds,
    Jon

    0
  33. 33

    Your timing is perfect. I just started looking into how to get these exact Twitter things accomplished this morning.

    Thanks for the great post and great information.

    Cheers,
    @CorradoCoia

    0
  34. 34

    very impressive! great post… Thanks! :D

    0
  35. 35

    awesome, will be trying this out

    0
  36. 36

    very useful for me, I will use some of the function in my blog.

    thanks

    0
  37. 37

    What’s a twitter? o.O

    0
  38. 38

    twitter for kids

    0
  39. 39

    Try Thread Twitter!

    0
  40. 40

    Wow thanks for these! I love good twitter icons.

    0
  41. 41

    Those are cool hacks. But you do not need to modify your wordpress/theme files to incorporate them or install a bucket full of plugins. You just need one plugin that can add all these hacks (and whatever else you want) automatically to your posts WordPress Prefix Suffix

    0
  42. 42

    robin @ elements, inc.

    March 6, 2009 9:38 am

    thanks a bunch for these cool plug ins!

    0
  43. 43

    dig the “Display your latest tweet without a plug-in” thanks!

    0
  44. 44

    Rogério Oliveira

    March 6, 2009 10:45 am

    fodastico

    0
  45. 45

    wow, great!
    change name to “twitter magazine”
    : /

    0
  46. 46

    This is friggin’ awesome. Thanks SM!

    0
  47. 47

    hey, nice content

    0
  48. 48

    Nice, thank you!

    0
  49. 49

    A question… are these tips available for WordPress.com hosted blogs also? I haven’t yet gotten into customizing CSS, are these some of the things I can do once I dare dive in? ;)

    0
  50. 50

    Question: how can I insert one of this Twitter icons in the sidebar of my blog? http://www.inspiredm.com/2009/03/02/twitter-art-the-most-inspirational-twitter-graphics/

    0

↑ Back to top