This week, Twitter has announced a new feature: the official Tweet Button. This feature will allow publishers to add an official button to share their content via Twitter. Mashable has more information on the button and what this means for publishers and site owners.
I really like this idea and hope that this leads to more analytics from Twitter, similar to the Facebook Insights program.
I’ve started adding this new button to a few sites that I maintain and thought I’d share the (very simple) code for adding this to a WordPress blog template so that it appears on every post.
On this blog, I’m displaying the Twitter Button with a horizontal count. The link is a direct link to the blog post and with the title of the post serving as the Twitter content. In order to populate that, I’ve inserted the following code into the WordPress loop in my template:
<?php $twitVia = "noturnonred"; ?>
<a href="http://twitter.com/share" class="twitter-share-button" data-url="<?php the_permalink(); ?>" data-text="<?php the_title(); ?>" data-count="horizontal" data-via="<?php echo $twitVia; ?>">
Tweet
</a>
<script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script>
If you want to put this on your blog, just change the first variable from noturnonred to your own Twitter account name. After that, the permalink and page title will be properly inserted into the link and your button should appear on your blog posts.
For more information on the options available or to generate a different Tweet Button, visit the Tweet Button page on Twitter.


