Earlier today, Twitter announced its official Tweet button that does the exact same thing as the Tweetmeme buttons, except it's made by Twitter. Many people are already switching (this includes major corporations and small bloggers who follow @wpbeginner on twitter) because this button offers additional customization and has the option to recommend the next account. In this article, we will share how you can add Twitter tweet button in WordPress.
This code can be installed in single.php, loop.php, index.php, page.php, category.php and archive.php as long as it is placed inside the post loop.
Pío
Tweet
Try tweeting using the button above..
If you notice that in the code above, we're using the anchor tag's data attribute to tell Twitter exactly what we want it to do. Below is the explanation of what each property means:
We recommend users to use the data attribute of the anchor tag method because it keeps the code clean and short. Although query string parameters are a convenient way to share your page, they can make your anchor tag very long, and it's difficult to maintain a long URL, especially when you have to encode the URL parameters. Below is the query method for those who choose to use it:
& via = wpbeginner & count = horizontal "> Tweet
If you just want to add a tweet button on a static page, you can use Twitter's Twitter Button Builder.
Thanks to Otto for letting us know in the comment below that his plugin, Simple Twitter Connect, is fully compatible with the official tweet button.
Additional Resources:
Supplemental documentation for the Tweet button