How to Add Twitter Tweet Button in WordPress Site

Twitter launches Official Tweet Button a way to share your site articles or pages, experiences into all twitter users, followers in just a few clicks and this is really good to all bloggers. If you still remember a Tweetmeme button these buttons do exact same thing the best is, this is made by Twitter.

Twitter is other way to share you thoughts, news online so I decided to create this post to help you add twitter tweet button in your WordPress or HTML site, in an easy way.

This code can be installed in index.php, single.php, page.php, category.php, and archive.php, tag.php as long as it is placed within the post loop.

Demo can be found on every post here in my site.


  • data-url: This fetches the URL that you want to share (You do not need to change this).

  • data-via: This tells twitter who was the original tweeter by adding via @wpbeginner(Make sure you change it to your twitter account).

  • data-text: This fetches the title of your post (You do not need to change this).
  • data-related: This adds recommended users to follow. You are allowed up to two Twitter accounts for users to follow after they share content from your website. These accounts could include your own, or that of a contributor or a partner. The first account is the one that is shared in data-via property. (Make sure you change it to one of your other twitter accounts, or remove it). If you don’t, then you will be recommending @syedbalkhi(Founder of WPBeginner). The correct format to enter data in this variable istwitterusername:Description of the User.

  • data-count: This tells twitter’s script which style of button you want to show. You have three option (vertical, horizontal, none).

  • data-lang: This variable tells twitter which language it should be in. Default value is ‘en’ for English, and we have left it at that.

Don’t want to touch anything in the php file?

Well that’s not a problem you can use the plugin provided by other developer.

Simple Twitter Connect this plugin fully supports the official tweet button.

by Ryan Sutana