Beginner's Guide for WordPress / Start your WordPress Blog in minutes

How to Display Social Media Followers Count in WordPress

Do you want to easily display social media followers count as text in WordPress?

Displaying social media followers count helps you add social proof to your website, strengthens brand identity, and helps you grow your business.

In this article, we’ll show you how to easily display social media followers count as text in WordPress.

Show social media follower count in WordPress

Why Show Social Media Followers Count on Your Website?

You may have noticed that many of the popular blogs, influencers, and brands proudly display their social media follower count on their websites.

Followers count helps you add social proof to your WordPress website. This allows you to earn users’ trust and build brand identity by showing your previous customers and followers as proof.

Social media follower count preview

Plus, it helps you get more followers on your social media profiles while allowing users convenient ways to stay in touch.

Unfortunately, it is not as simple or easy to display social media followers count as we would like it to be, but it is most definitely possible.

Many social media platforms require API keys to fetch this information and each of them has a different way of doing this.

Luckily, there are several WordPress plugins and solutions that makes it possible for you to display social follower count.

That being said, we’ll show you different ways to display your social media follower count on your WordPress website. You can choose one that works best for you.

Method 1. Display Social Media Follower Count using a Plugin

This method is easier and allows you to skip the API Keys requirement if you are unable to get them.

However, it is a bit unreliable and may not be able to fetch the follower count in real-time. That’s because social media platforms change their API key methods quite frequently which breaks applications using the old methods.

The good part is that plugin provides a fallback option to manually enter your social media follower count as text.

First, you need to install and activate the Wp Social plugin. For more details, see our step by step guide on how to install a WordPress plugin.

Upon activation, you need to go to WP Social » Social Counter page and switch to the Providers tab.

Social counter settings

From here, you need to turn on each social media platform that you want to display and then click on the Settings button to set it up.

This will bring up a popup where you can provide your social media profile details for that platform. You’ll also find an option to enter a default Facebook follower count manually.

Platform settings

Repeat the process for all social media platforms that you want to display.

Once you are finished, you can go to Appearance » Widgets page and add the WSLU Social Counter widget to your sidebar.

Display social follower count in sidebar widget

Don’t forget to save your changes and preview your website.

Want to display social media follower count in a post or page? Simply edit the post or page where you want to show follower count and add the following shortcode in the content editor.

[xs_social_counter]
Add shortcode

After that, you can save or publish your post or page and preview to see your social media follower count in action.

Social media follower count preview

Method 2. Display Social Media Feeds with Smash Balloon

An easier alternative to showing social media follower counts is showing your social feeds with Smash Balloon.

Smash Balloon is the best social media plugin for WordPress. It allows you to easily display content from your social media feeds with beautiful layouts.

First, you need to visit the Smash Balloon website. They offer different social media feed plugins for Instagram, Twitter, Facebook, YouTube, and a combined Social Wall feed.

Smash Balloon website

We recommend getting the All Access Bundle which gives you all the plugins.

After signing up, you can login to your account on the Smash Balloon website and download the plugins to your computer.

Next, you can go ahead and install Smash Balloon feed plugins one by one. For more details, see our step by step guide on how to install a WordPress plugin.

For the sake of this tutorial, we’ll show you how to create a social wall which helps you connect all your social media feeds and display them as one.

Upon plugin activation, go to Social Feeds » Create a Social Wall page. From here, you’ll see the list of social feeds with buttons to connect them.

Connect social feeds

Once you have connected the feeds, you’ll see a shortcode at the top to use anywhere on your website to display the social wall.

Social wall shortcode

You can now add this shortcode to any WordPress post, page, or sidebar widget to display your social feeds.

Not happy with the look? Smash Balloon gives you a bunch of customization options and layouts for your social feeds.

Simply go to the Social Feeds » Create a Social Wall page and switch to the Customize tab.

Customize feed

From here, you can choose a layout type and configure display options like header, footer, number of items, and more.

Once you are finished, don’t forget to save your changes,.

Here is how a typical social wall feed would look like on your website.

Social wall preview

Smash Balloon can also show individual feeds for each social media platform. Simply switch to the feed menu to copy the shortcode.

Display a single feed separately

After that, you can add this shortcode to any post, page, or sidebr widget to display that particular feed. Some feeds like Facebook page may even show follower count.

Facebook widget with follower count

For detailed instructions, see our step by step guide on:

Smash Balloon offers a free version of all their Pro plugins which is great for those who’re on a budget.

Method 3. Manually Fetch & Display Follower Count Using Code

This method is a bit advanced and may not work very well for beginners. However, it will help you fetch the social media follower count as text.

Basically, most social media platforms require you to create an App and user API keys to retrieve data like follower count from their servers.

In this method, we will show you how to get follower count for Twitter and Facebook using API keys.

You’ll need to add custom code to your WordPress website. If you haven’t done this before then take a look at our guide on how to copy and paste code in WordPress.

Show Facebook Follower Count Using Code

To fetch facebook follower count, you will need the following items.

  1. Create a Facebook app to get access to Facebook APIs.
  2. Generate an access token. This acts as a password and lets you fetch the information you need.
  3. Use Facebook app and access token to get Facebook likes in WordPress

1. Create Facebook App

Let’s start by creating a Facebook app. Simply go to the Facebook Developers website and click on the Create an App button.

Create a Facebook app

After that, you will be asked to choose an app type. Click on the Business and then click on the Next button to continue.

Choose app type

After that, you will be asked to give your app name (this could be anything you want), and email address. You can skip the business account option and click on the Create App button.

Provide app details

You may be prompted to enter your Facebook password. After that, you will be redirected to your app dashboard.

App dashboard

On this screen, you will see multiple options, but since we are using the app for personal use, we don’t need these options at the moment.

2. Get Access Token for Facebook API

Next, you need to head over to the Graph API explorer page to generate our access token and get our page ID.

Generate Facebook token

First, select the app you created under the Facebook App section.

After that, click on the Get Token drop-down menu and select the Page Access Token option.

This will bring up the permissions popup, where you need to continue as your personal account, and then choose the page you want to get access token for.

Choose page

Next, you will be shown some permissions and warnings. You can ignore these and click Done.

Permissions

Facebook will now generate an access token for you. Simply copy and paste the access token in your computer using a plain text editor like Notepad or TextEdit.

Copy access token

Before you leave, the next thing you need is the Page ID. To get this, you need to enter your page URL slug in the form above, and then click on the Submit button.

Get page ID

You can now copy and paste the Page ID on your computer using a plain text editor like Notepad or TextEdit.

3. Display Facebook Likes in WordPress

First, you need to copy and paste the following code to your WordPress your theme’s functions.php file or a site-specific plugin.

function getFacebookLike( $fbid, $token ){ 
$json_string = @file_get_contents('https://graph.facebook.com/v14.0/'. esc_attr( $fbid ) .'/?fields=fan_count&access_token='. esc_attr( $token ) );
$json = json_decode($json_string, true); 
$like_count = isset( $json['fan_count'] ) ? $json['fan_count'] : 0;
return $like_count;
}

Next, you need to paste the following code in your WordPress theme template where you want to display the Facebook Like count as text.

<?php 
echo "<p>More than <strong>" . getFacebookLike( $fbid = 'Facebook page ID', 'access token' ) .  "</strong> users follow us on Facebook.</p> "; 
?>

Don’t forget to replace Facebook page ID and access token with the values you copied earlier.

You can now visit your website to see your code in action. Here is how it looked on our test website.

Facebook follower count

Show Twitter Follower Count as Text

To get Twitter follower count as text, you’ll need to follow these steps.

  1. Create Twitter App
  2. Get Twitter API key
  3. Fetching follower count in WordPress

1- Create Twitter App and Get API Keys

First you need to visit the Twitter Developer website and create a new standalone app.

Create Twitter app

You’ll be asked to provide a name for your app. You can choose any name you want.

Twitter app name

Next, you will see API keys for your app. Go ahead and copy these keys on your computer using a plain text editor like Notepad and TextEdit.

Twitter API keys

2- Fetch Twitter Follower Count in WordPress

Next, you need to add the following code to your theme’s functions.php file or a site-specific plugin.

function getTwitterFollowers($screenName = 'wpbeginner')
{
    // some variables
    $consumerKey = 'API key';
    $consumerSecret = 'API key secret';
    $token = get_option('cfTwitterToken');
 
    // get follower count from cache
    $numberOfFollowers = get_transient('cfTwitterFollowers');
  
    // cache version does not exist or expired
    if (false === $numberOfFollowers) {
        // getting new auth bearer only if we don't have one
        if(!$token) {
            // preparing credentials
            $credentials = $consumerKey . ':' . $consumerSecret;
            $toSend = base64_encode($credentials);
  
            // http post arguments
            $args = array(
                'method' => 'POST',
                'httpversion' => '1.1',
                'blocking' => true,
                'headers' => array(
                    'Authorization' => 'Basic ' . $toSend,
                    'Content-Type' => 'application/x-www-form-urlencoded;charset=UTF-8'
                ),
                'body' => array( 'grant_type' => 'client_credentials' )
            );
  
            add_filter('https_ssl_verify', '__return_false');
            $response = wp_remote_post('https://api.twitter.com/oauth2/token', $args);
  
            $keys = json_decode(wp_remote_retrieve_body($response));
  
            if($keys) {
                // saving token to wp_options table
                update_option('cfTwitterToken', $keys->access_token);
                $token = $keys->access_token;
            }
        }
        // we have bearer token wether we obtained it from API or from options
        $args = array(
            'httpversion' => '1.1',
            'blocking' => true,
            'headers' => array(
                'Authorization' => "Bearer $token"
            )
        );
  
        add_filter('', '__return_false');
        $api_url = "https://api.twitter.com/1.1/users/show.json?screen_name=$screenName";
        $response = wp_remote_get($api_url, $args);
  
        if (!is_wp_error($response)) {
            $followers = json_decode(wp_remote_retrieve_body($response));
            $numberOfFollowers = $followers->followers_count;
        } else {
            // get old value and break
            $numberOfFollowers = get_option('cfNumberOfFollowers');
            // uncomment below to debug
           die($response->get_error_message());
        }
  
        // cache for an hour
        set_transient('cfTwitterFollowers', $numberOfFollowers, 1*60*60);
        update_option('cfNumberOfFollowers', $numberOfFollowers);
    }
  
    return $numberOfFollowers;
}

Don’t forget to replace wpbeginner with your own Twitter username and API keys with your own API keys.

Aftet that, you can add the following code to your WordPress theme where you want to display the Twitter follower count.

<p>
More than <strong><?php echo getTwitterFollowers(); ?></strong> users follow us on Twitter.
</p>

You can now visit your website and see your Twitter follower count in action.

Twitter follower count

We hope this article helped you display social media followers count in WordPress. You may also want to see our complete social media cheat sheet for WordPress or see our WordPress SEO guide to get more organic traffic from search engines.

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

Disclosure: Our content is reader-supported. This means if you click on some of our links, then we may earn a commission. See how WPBeginner is funded, why it matters, and how you can support us.

The Ultimate WordPress Toolkit

Get FREE access to our toolkit – a collection of WordPress related products and resources that every professional should have!

Reader Interactions

19 CommentsLeave a Reply

    • Thank you for letting us know, we will be sure to look into alternative options. :)

      Admin

  1. In my wordpress website I am not able to trace from where the social counter is working. The FB, twitter and other are showing but with zero value.

  2. Hi,

    First of all thank you for your tips and tricks. :)
    I have from nowhere lost all my twitter and pinterest and some google+ social counts in my posts. Facebook still works. I haven’t changed permalinks.

  3. Great tutorial. I’ve managed to get everything working in my blog page, reglazeglasses4u.co.uk/blog.html using the widgets but I can’t get any of the icons to show up on either pages or posts using the shortcodes. Any ideas?

    • I was able to generate a G+ API, but it’s not displaying my G+ follower count. Bummer.

  4. Wow! This is very easy tutorial to install Social Count Plus plugin and then develop application on Twitter in order to display social media followers count as text. I didn’t try this on my blog but after finding this tutorial I will experience it on my blog to make it prettier :)

  5. It is always a keen query done by bloggers. The main point is about designing the website in which social media icons helps a lot. The question asked by many about arranging these buttons followed by the number count under them is a matter to solve. I hope the plugin about which you have explained will work properly.
    Thanks for sharing.

  6. Hi, and please excuse my english… I’m fighting with this plugin that seems really good but the facebook counter doesn’t grow up :-(
    I tried with my facebook id, and with before my id like recommended here : http://wordpress.org/support/topic/fb-not-updating but my facebook count is frozen at 85 therefore it’s now 97 :-(
    so I’m searching for another one…

  7. This plugin is very good, I use it on my blog since the first version. Thanks, Claudio Sanches available for it.

  8. I never imagined that someday my plugin would have some here: D
    Many thanks for talking about my plugin *____*

  9. Thanks for the info.

    This seems very complicated for something one sees on many sites. My old wordpress.com site displayed total followers automatically if I used its publicize function.

    Isn’t there an easier way with a plugin?

    • We found this to be the easiest way to accomplish this. Just follow through the instructions step by step. Let us know which part feels more complicated to you and we will try to further explain it for you.

      Admin

Leave a Reply to Gary Neal Hansen Cancel reply

Thanks for choosing to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and your email address will NOT be published. Please Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.