How to Powerfully Display Your Twitter Follower Count as Text in WordPress (2023)

Want to establish instant credibility with your WordPress site visitors? Showing off your Twitter follower count as text is a proven way to build trust and encourage more people to follow you.

By displaying your follower count prominently on your site, you send a strong signal that you‘re an authority in your niche. It‘s a quick and effective form of social proof – a psychological phenomenon where people look to the actions of others to guide their own behavior.

Consider these eye-opening stats:

  • 92% of consumers trust word-of-mouth or recommendations from friends and family above all other forms of advertising (Nielsen)
  • The average consumer reads 10 online reviews before making a purchase decision (Brightlocal)
  • Social proof is the 2nd most influential factor in online purchasing decisions, behind only discounts and free shipping (Invesp)

Clearly, showcasing your social media popularity can give you a major credibility boost. And with over 192 million daily active users on Twitter (Oberlo), it‘s one of the most powerful platforms for demonstrating your influence.

In this ultimate guide, we‘ll walk you through exactly how to display your Twitter follower count as text anywhere on your WordPress site. No plugins required – just a bit of code that even total beginners can implement!

Step 1: Apply for a Twitter Developer Account

The first step to showing your Twitter follower count on WordPress is registering for a developer account. This will give you access to the Twitter API (Application Programming Interface) which is necessary for fetching your live follower data.

To get started, head to the Twitter Developer Portal and click the "Apply" button.

Apply for a Twitter Developer Account

You‘ll need to sign in with your regular Twitter account details. If you don‘t already have a Twitter account, you‘ll need to create one first.

Once logged in, Twitter will ask you to select your primary reason for using the developer platform. Choose the "Exploring the API" option.

Twitter API Use Case

On the next screen, you‘ll need to provide some additional information about your intended use case. Select "Making a bot" and explain that you want to display your public Twitter metrics on your personal website to build credibility and showcase your influence in your industry. Aim for at least 200 characters in your description to satisfy the requirements.

After confirming your information and accepting the developer agreement, submit your application. The approval process is usually quick, often within a few minutes. You‘ll receive an email confirmation once your developer account is fully activated.

Step 2: Create a Twitter App and Get API Credentials

Now that you have an approved developer account, your next step is to create a Twitter "app" and generate the necessary API credentials.

From your developer dashboard, navigate to the "Apps" page and click the "Create an app" button.

Create a Twitter App

Fill out the required fields for your app:

  • App name: Choose a descriptive name like "WordPress Follower Count"
  • Application description: Briefly explain the app‘s purpose, e.g. "Displays my Twitter follower count on my WordPress website"
  • Website URL: Enter the URL of your WordPress site
  • Tell us how this app will be used: Provide a clear use case, such as "This app will use the Twitter API to fetch my current follower count and display it as text on various pages of my WordPress site to boost credibility and encourage more followers."

Agree to the developer terms and submit your app for creation. You should see a success message confirming that your app has been created.

From the app dashboard, navigate to the "Keys and tokens" tab. Here you‘ll find your API credentials:

  • API Key
  • API Secret Key
  • Bearer Token

Copy and store these credentials in a secure location. You‘ll need them in the next step to authenticate your WordPress site to fetch follower data from the Twitter API. Never share your API credentials publicly as they allow access to your Twitter account.

Step 3: Use a Code Snippet to Fetch and Display Follower Count in WordPress

Now it‘s time to put your API credentials to work in WordPress. We‘ll use a custom code snippet to fetch your current follower count from the Twitter API and display it as text.

We recommend using the free Code Snippets plugin to manage custom code in WordPress. It‘s a safe and easy way to add PHP snippets to your site without directly editing theme files. The plugin also makes it simple to control where and when the snippet should run.

After installing the Code Snippets plugin, navigate to Snippets > Add New in your WordPress admin dashboard.

Create a new snippet with a descriptive name like "Twitter Follower Count" and paste in the following PHP code:

<?php
function display_twitter_follower_count() {
    $twitter_username = ‘your_username‘;
    $api_key = ‘your_api_key‘;
    $api_secret = ‘your_api_secret‘;

    // Check for cached follower count
    $follower_count = get_transient( ‘twitter_follower_count‘ );

    // If no cached count, fetch from Twitter API
    if ( false === $follower_count ) {
        // Get API access token
        $bearer_token = get_transient( ‘twitter_bearer_token‘ );

        if ( false === $bearer_token ) {
            // Get new bearer token
            $bearer_credentials = base64_encode( $api_key . ‘:‘ . $api_secret );
            $args = [
                ‘httpversion‘ => ‘1.1‘,
                ‘blocking‘ => true,
                ‘headers‘ => [
                    ‘Authorization‘ => ‘Basic ‘ . $bearer_credentials,
                    ‘Content-Type‘ => ‘application/x-www-form-urlencoded;charset=UTF-8‘,
                ],
                ‘body‘ => [‘grant_type‘ => ‘client_credentials‘],
            ];

            $response = wp_remote_post( ‘https://api.twitter.com/oauth2/token‘, $args );

            if ( is_wp_error( $response ) || 200 !== wp_remote_retrieve_response_code( $response ) ) {
                return false;
            }

            $body = json_decode( wp_remote_retrieve_body( $response ) );
            $bearer_token = $body->access_token;

            // Cache bearer token for 1 hour
            set_transient( ‘twitter_bearer_token‘, $bearer_token, HOUR_IN_SECONDS );
        }

        // Fetch follower count from API
        $args = [
            ‘httpversion‘ => ‘1.1‘,
            ‘blocking‘ => true,
            ‘headers‘ => [
                ‘Authorization‘ => ‘Bearer ‘ . $bearer_token,
            ],
        ];

        $api_url = ‘https://api.twitter.com/1.1/users/show.json?screen_name=‘ . $twitter_username;
        $response = wp_remote_get( $api_url, $args );

        if ( is_wp_error( $response ) || 200 !== wp_remote_retrieve_response_code( $response ) ) {
            return false;
        }

        $body = json_decode( wp_remote_retrieve_body( $response ) );
        $follower_count = $body->followers_count;

        // Cache follower count for 1 hour
        set_transient( ‘twitter_follower_count‘, $follower_count, HOUR_IN_SECONDS );
    }

    return $follower_count;
}

Make sure to replace your_username, your_api_key, and your_api_secret with your actual Twitter username and API credentials from the previous step.

Here‘s a quick breakdown of what this code does:

  1. First, it checks for a cached follower count stored as a WordPress transient. Transients are a way to temporarily store data in the WordPress database to improve performance by minimizing external API requests.

  2. If no cached count exists, the code checks for a cached bearer token (also stored as a transient). The bearer token is used to authenticate API requests. If no token is found, a new one is generated using the provided API key and secret, then cached for 1 hour.

  3. Using the bearer token, the code makes a request to the Twitter API‘s users/show endpoint, passing your Twitter username to retrieve your account data.

  4. The API response is parsed to extract the followers_count value, which is then cached as a transient for 1 hour to prevent hitting API rate limits.

  5. Finally, the follower count is returned and can be displayed on the front-end of your WordPress site.

After configuring the code snippet, be sure to set its status to "Active" and select the "Only run on site front-end" option. This ensures that the code will run efficiently without slowing down your WordPress admin dashboard.

Click the "Save Changes and Activate" button to store your snippet and enable the Twitter follower count fetching functionality.

Step 4: Display Your Follower Count with a Shortcode

With your code snippet in place and collecting follower data, you can display your count anywhere on your WordPress site using a simple shortcode.

Shortcodes are small snippets of code wrapped in square brackets that output dynamic content when placed in posts, pages, or widgets.

We‘ll use the Shortcoder plugin to create a custom shortcode for the Twitter follower count. It‘s an easy way to manage reusable shortcodes without writing complex functions.

Install and activate the free Shortcoder plugin, then navigate to Settings > Shortcoder to add a new shortcode.

Create a shortcode with a clear name like [twitter_follower_count] and paste in the following shortcode content:

<?php echo number_format( display_twitter_follower_count() ); ?>

This code simply outputs the result of the display_twitter_follower_count function we created earlier, formatting the number for better readability.

Save your shortcode, and you‘re ready to start displaying your Twitter follower count on your WordPress site!

Some ideas for prominent placement:

  • In a header or footer widget
  • As part of an author bio box below blog posts
  • On your "About" or "Contact" page
  • In a sidebar widget alongside social media icons

For example, you could display your follower count in a sentence with a link back to your Twitter profile:

<p>Join over <a href="https://twitter.com/your_username">[twitter_follower_count]</a> others following me on Twitter!</p>

Or add some visual flair with icons and styling:

<div class="follower-count">
  <span class="icon"><i class="fab fa-twitter"></i></span>
  <span class="count">[twitter_follower_count]</span>
  <span class="label">Twitter Followers</span>
</div>
.follower-count {
  display: flex;
  align-items: center;
  font-size: 1.2rem;
  color: #1DA1F2;
}

.follower-count .icon {
  margin-right: 10px;
}

.follower-count .count {
  font-weight: bold;
  margin-right: 5px;
}

Feel free to get creative and adapt the shortcode output to seamlessly integrate with your WordPress theme design. The key is making your follower count highly visible to maximize its impact.

Here‘s an eye-catching example from marketing expert Neil Patel‘s blog:

Neil Patel Twitter Follower Count

Notice how the follower count is strategically placed next to Neil‘s photo and bio to instantly communicate his authority and influence. This prominent social proof makes readers more likely to trust his advice and sign up for his email list.

Advanced Tips for Maximizing Follower Count Impact

Once you‘ve successfully implemented your Twitter follower count on WordPress, here are a few next-level strategies to drive even better results:

Encourage Clicks with a Strong Call-to-Action

Don‘t just display your follower count – actively encourage visitors to become followers too! Add a prominent CTA (call-to-action) near your count to drive clicks to your Twitter profile.

For example: "See why over 10K marketers follow me for the latest social media tips!"

Cross-Promote Your Twitter and WordPress Content

Maximize engagement and followers by regularly sharing your WordPress blog content on Twitter. Use attention-grabbing visuals, quotes, or statistics from your posts to entice Twitter users to click through to your site.

Similarly, embed relevant tweets in your WordPress posts to encourage blog readers to follow you for more timely updates and insights.

Leverage the Twitter Follow Button

In addition to displaying your follower count, consider adding an official Twitter Follow button to your WordPress site. This makes it quick and easy for visitors to follow you without leaving your site.

You can add the button using a simple code snippet or with the official Twitter plugin for WordPress.

Display Follower Counts for Multiple Accounts

Want to showcase your influence across several Twitter accounts? With a few tweaks to the code snippet, you can fetch and display follower counts for any number of profiles.

This is a great strategy for agencies, influencers, or brands managing multiple Twitter accounts. It allows you to provide social proof for all your profiles in one place.

Keep Your Follower Count Fresh

Since Twitter follower counts can change frequently, it‘s important to keep your displayed number as current as possible.

The code snippet in this guide caches the count for 1 hour to avoid excessive API requests, but you can adjust the caching duration by modifying the HOUR_IN_SECONDS parameter.

Find the right balance between fresh data and performance based on your site‘s needs and traffic.

Conclusion

Displaying your Twitter follower count on your WordPress site is a powerful way to boost your credibility and authority. By showing visitors that thousands of people already follow and trust you on Twitter, you can encourage even more followers and subscribers.

As we‘ve covered in this comprehensive guide, implementing a dynamic follower count on WordPress is easier than you might think. With a few strategic code snippets and thoughtful placement, you can start leveraging Twitter social proof to build an engaged audience across platforms.

Experiment with different follower count display options to see what resonates best with your audience and brand. By keeping your count prominent and up-to-date, you can maximize its impact and drive real results for your business.

Remember, social media marketing success is all about credibility, consistency, and connection. Showcasing your Twitter followers on WordPress is just one piece of a larger strategy to build trust and grow your community online.

For more expert tips and tools to accelerate your Twitter growth, check out our complete Twitter Marketing Handbook or schedule a free consultation with our social media strategists.

Let‘s boost your influence on Twitter and beyond!

Did you like this post?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate this post.