BLOG

“I still suggest you call
this page 42Lab.
Works for both of us!”
- Joey

WordPress 101: Tips, Tricks and Hacks (Display Twitter counter as Text)

Since the day WordPress came into the industry it has been a source of disruption. This disruption has enabled WordPress to not only lead the market but also a sizable chunk of the internet. While other Content Management Systems might some tricks under their sleeves. WordPress has an extensive array of features that provide unparalleled value.  

This value provided by WordPress is what makes it the favorite Content Management System of many users. The online community of content creators, small to medium business owners and enthusiasts. I have been greatly empowered by WordPress and its platform.  

It is this empowerment that has led to an explosion of creatives from all walks of life to join the internet and create content. Content that moves people, content that connects people that is what the real strengths of WordPress are. As times change, online bloggers also need to change. The first step towards that direction would be to integrate social media within your blog. 

Twitter by far is one of the most important social media platforms for an online blogger. Therefore the ability to integrate Twitter with your blog can enable you to grow faster and better! Take one step and allow your readers to follow you on Twitter.

Official Twitter follow button offers a simple way out when one wants to showcase its twitter followers. However, this may slow your website due to the Twitter script loading. 

Also, if you intend to create something customized and want Twitter follower count as text and not a button, Twitter button doesn’t help. 

So, is there a way out? There, definitely is. 

WordPress Hack: Display Twitter count as Text

Our small tutorial will assist you in displaying your Twitter follower count as text on your WordPress site. 

Create a file called twitter.php and paste the following code in that file.

<?php

$tw = get_option("twitterfollowerscount");

if ($tw['lastcheck'] < ( mktime() – 3600 ) )

{

$xml=file_get_contents('https://twitter.com/users/show.xml?screen_name=twitterhandle');

if (preg_match('/followers_count>(.*)</',$xml,$match)!=0) {

$tw['count'] = $match[1];

}

$tw['lastcheck'] = mktime();

update_option("twitterfollowerscount",$tw);

}

echo $tw['count'];

?>

Make sure you replace your twitterhandle with your twitter handle. Then, replace the below code to your sidebar.php file.

<?php include("twitter.php"); ?>

That’s it!

You have successfully created it on your WordPress Site!

 

Previous Hack: How To Link External Links From Post Titles

42 works

Exploring the Future of Apps with Apple

Read Blog

Dream Bigger. Work Greener.
Explore Our New & Sustainable Workspace

READ POLICY
42 works
Get 42Works Blog updates in your Inbox!

    Phone Button +91-9517770042 whatsapp Button Chat With Us
    Ohio United States 13.59.226.71 https://42works.net/display-twitter-count-as-text-in-wordpress/