Family Encyclopedia >> Electronics

How to Integrate Twitter @Anywhere into Your WordPress Site: Step-by-Step Guide

Twitter's @Anywhere platform revolutionized social integration by embedding powerful features into websites using simple JavaScript. As experienced WordPress developers, we've seen it boost tweets, traffic, follows, interactions, and user engagement. Key features include on-site tweet boxes, auto-linked usernames like @wpbeginner, hovercards with follow buttons, connect buttons, and more. With Twitter's growth, it promised to shape the social web. This guide shares proven steps to add @Anywhere to your WordPress blog.

Important Update: Twitter disabled the @Anywhere API on December 6, 2012. For modern alternatives, explore Twitter Cards or oEmbed.

Step 1: Register an API Key

To start, register for a Twitter API key via their developer portal. The signup page looks like this:

How to Integrate Twitter @Anywhere into Your WordPress Site: Step-by-Step Guide

Once approved, note your API key. Crucially, set permissions to 'Read & Write' so follow buttons function properly—a common Twitter hiccup we're addressing here.

Navigate to https://twitter.com/oauth, select your app, click 'Edit Application Settings,' and change 'Default Access Type' to 'Read & Write.'

Step 2: Implement on Your Site

Add the core script to your theme's header.php within the <head> section:

<script type="text/javascript" src="https://platform.twitter.com/anywhere.js?id=YOUR_API_KEY&v=1"></script>

Replace YOUR_API_KEY with your actual key. Now enable features individually by adding these scripts below it.

Auto-Link Twitter Usernames

Automatically hyperlinks @usernames in posts and comments (e.g., @wpbeginner), saving manual linking time. Excludes links, scripts, iframes, etc.

twttr.anywhere(function(twitter) {
  twitter.linkifyUsers();
});

Hovercards for Usernames

How to Integrate Twitter @Anywhere into Your WordPress Site: Step-by-Step Guide

Links usernames and shows hovercards on mouseover, revealing profiles and follow buttons—users can follow directly from your site.

twttr.anywhere(function(twitter) {
  twitter.hovercards();
});

Smart Follow Buttons

How to Integrate Twitter @Anywhere into Your WordPress Site: Step-by-Step Guide

Create customizable follow buttons for posts or sidebars. Example:

twttr.anywhere(function(twitter) {
  twitter("#follow-wpbeginner").followButton("wpbeginner");
});

Add this HTML where desired:

<div id="follow-wpbeginner"></div>

Swap 'wpbeginner' for your username.

Live Tweet Box

How to Integrate Twitter @Anywhere into Your WordPress Site: Step-by-Step Guide

Embed a fully functional tweet composer—users tweet without leaving your site. Powerful for engagement; customizable for retweets too.

twttr.anywhere(function(twitter) {
  twitter("#custom-tweetbox").tweetBox({
    label: "Live Tweet Box:",
    defaultContent: "Everyone should follow @wpbeginner for amazing #WordPress tips",
    height: 50,
    width: 480
  });
});

Insert this HTML:

<div id="custom-tweetbox"></div>

WordPress plugins offer basics like hovercards, but manual implementation is lightweight and reliable.

Liked this? Retweet or comment if we missed anything.

Additional Resources:

Twitter @Anywhere Documentation
Simple Twitter Connect plugin (shoutout to Otto for this gem)