Setup Twitter @Anywhere for WordPress in Seconds!

Hey there! I'm currently working on a CLI tool to deploy WordPress apps to DigitalOcean. Check it out! It's free and open source.

That’s right, seconds! The twitter @Anywhere was introduced at SXSW conference and launched the dev tools a couple of days ago. It’s a simple javascript-driven set of tools that allows you to basically integrate Twitter functionality anywhere on your websites. Usage is as simple as loading a javascript file and launching a couple of js commands, which instantly give you the power of Twitter on your own blog. Personally, I’m amazed, and couldn’t help integrating it here on my blog. Hover your mouse over @kovshenin to see the hovercards in effect ;) Sweet eh?

It took me around 40 seconds to get this thing to work. This includes downloads and uploads file to the server ;) So open up your functions.php file and paste the following code:

$api_key = "Replace with your API key";
wp_enqueue_script("twitter-anywhere",
	"http://platform.twitter.com/anywhere.js?id={$api_key}&v=1");
add_action("wp_head", "twitter_anywhere");

function twitter_anywhere()
{
	echo '<script type="text/javascript">';
	echo 'twttr.anywhere(onAnywhereLoad);';
	echo 'function onAnywhereLoad(twitter) { twitter.hovercards(); }';
	echo '</script>';
}

That’s it. Literally. That’s all you have to do to fire your hovercards throughout your blog! Just make sure you get an API key before right over here. The Anywhere documentation is all javascript and pretty straightforward, I’m sure you’ll figure it out.

I also looked at the WordPress Plugin Directory for ones registered with the “anywhere” names and guess what! I found at least three of them – anywhere, twitter-anywhere and wp-twitter-anywhere ;) Why write a plugin for something that’s so dead simple? Oh well.. It’s funny how people rush to register WordPress plugin names when something new turns out. Same happened with Google Wave, and there’s still no good Wave plugin for WordPress ;)

About the author

Konstantin Kovshenin

WordPress Core Contributor, ex-Automattician, public speaker and consultant, enjoying life in Moscow. I blog about tech, WordPress and DevOps.

8 comments