Family Encyclopedia >> Electronics

How to Add the Official X (Twitter) Follow Button to Your WordPress Site

As seasoned WordPress developers, we've integrated social features like the official X (formerly Twitter) Follow Button across countless sites. This compact widget lets visitors follow any X account directly from your page, boosting engagement effortlessly. Unlike the older 'smart follow' button, which required full Twitter Anywhere setup and lacked customization, the official version displays follower counts and integrates seamlessly.

What is the X Follow Button?

The X Follow Button is a lightweight widget that opens a preview window with user details upon click. See the demo in the image below (top-left corner):

How to Add the Official X (Twitter) Follow Button to Your WordPress Site

It stands out from the smart follow button by supporting follower count display and simple setup—no complex integrations needed. Live example:

Step-by-Step: Adding the Official X Follow Button to WordPress

Visit the Follow Button generator or use this code (replace @wpbeginner with your handle):

<a class="twitter-follow-button" href="https://twitter.com/YOUR_USERNAME">Follow @YOUR_USERNAME</a>
<script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>

If you're already using the official Tweet Button, skip the script tag to avoid duplicates:

<a class="twitter-follow-button" href="https://twitter.com/YOUR_USERNAME">Follow @YOUR_USERNAME</a>

Paste into your theme's sidebar.php or use a Text widget: Go to Appearance » Widgets, drag a Text widget to your sidebar, and add the code. Here's an example:

How to Add the Official X (Twitter) Follow Button to Your WordPress Site

No plugins required for this straightforward task—keep your site lean and fast.

Advanced Customization Options

For developers and designers, tailor the button to your brand with these attributes:

  • data-show-count: true or false
  • data-size: large or small (formerly 'button')
  • data-text-color: Hex code (e.g., #ffffff)
  • data-link-color: Hex code
  • data-lang: en, fr, de, es (ISO-639-1)
  • data-width: e.g., 300px
  • data-alignment: left or right

Example with custom options:

<a class="twitter-follow-button" href="https://twitter.com/wpbeginner" data-show-count="true" data-size="large" data-text-color="#000000">Follow @wpbeginner</a>
<script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>

Resources:
Follow Button Documentation | Button Generator