How to Add Twitter’s Official Tweet Button in WordPress

Earlier nowadays, Twitter introduced their legit Tweet Button which does the very same factor because the Tweetmeme buttons apart from it’s made through twitter. A large number of individuals are already switching (this come with best corporates and small bloggers that observe @wpbeginner on twitter) as a result of this button gives further customization plus it has the choice to suggest account following. In this text, we will be able to proportion how you’ll upload twitter’s tweet button in WordPress.

This code may also be put in in unmarried.php, loop.php, index.php, web page.php, class.php, and archive.php so long as it’s positioned inside the submit loop.

<script src="" kind="textual content/javascript"></script>
   <a href="" elegance="twitter-share-button"
      data-url="<?php the_permalink(); ?>"
      data-text="<?php the_title(); ?>"
      data-related="syedbalkhi:Founder of WPBeginner"



Try tweeting the usage of the button above.

If you understand in the code above, we’re the usage of the data-attribute of anchor tag to inform twitter precisely what we wish it to do. Below is the rationale of what every assets way:

  • data-url – This fetches the URL that you need to proportion (You should not have to exchange this).
  • data-via – This tells twitter who was once the unique tweeter through including through @wpbeginner (Make positive you convert it to your twitter account).
  • data-text – This fetches the name of your submit (You should not have to exchange this).
  • data-related – This provides really helpful customers to observe. You are allowed up to two Twitter accounts for customers to observe once they proportion content material out of your web site. These accounts may come with your individual, or that of a contributor or a spouse. The first account is the person who is shared in data-via assets. (Make positive you convert it to certainly one of your different twitter accounts, or take away it). If you don’t, then you’re going to be recommending @syedbalkhi (Founder of WPBeginner). The right kind structure to input information in this variable is twitterusername:Description of the User
  • data-count – This tells twitter’s script which taste of button you need to display. You have 3 possibility (vertical, horizontal, none).
  • data-lang – This variable tells twitter which language it will have to be in. Default price is ‘en’ for English, and we’ve got left it at that.

We suggest customers to use the data-attribute of anchor tag approach as it assists in keeping the code blank and brief. Even regardless that question string parameters are a handy approach to proportion your web page, they are able to make your anchor tag very lengthy, and a protracted URL is tricky to handle particularly when you’ve got to URL encode parameters. Below is the question approach for many who make a selection to use it:

<script src="" kind="textual content/javascript"></script>
<a href="<?php echo urlencode(get_permalink($post->ID)); ?>&through=wpbeginner&depend=horizontal" elegance="twitter-share-button">Tweet</a>

If you simply need to upload a tweet button on a static web page, then you’ll use Twitter’s Tweet Button Generator.

Thanks to Otto for notifying us in the remark underneath that his plugin, Simple Twitter Connect, absolutely helps the legit tweet button.

Additional Resources:

Supplemental Documentation for Tweet Button

Recent Articles

The Best Pinterest Alternatives to Use if You are Bored of Pinterest

Pinterest is a loved social media network among the lover of aesthetics, mostly females tbh. Now, however more and more people are...

Ways you can add links to your Instagram post in 2021

Instagram has many cool features which need no introduction. However, there are a number of features that...

Finance App You should Have on Your iPhone and Android

We live in the age of digitization. When everything is digital, it is no surprise that money has joined the club too....

5 Video Editing Softwares to Try Your Hand at in 2021

Video is the king when it comes to social media. With reels dominating Instagram and Facebook and...

Charge Your Laptop Without a Charger in 5 Ways

Forgetting your laptop charger is a pretty common thing. We all have been there and all of...

Related Stories

Leave A Reply

Please enter your comment!
Please enter your name here