A Tweet This Button for Each Post in WordPress – Without a PluginBy Binny V A • Jun 9th, 2009 • Category: PHP, WordPress
TweetThis is a WordPress Plugin that ‘adds a Twitter link to every post and page, so your readers can share your blog entries on their Twitter accounts with ease.’ And in the tradition of my WordPress Plugin Killer Series, this post will show you how to do it without a plugin.
You can add twitter button to your post by editing the
single.php file in your theme. Go to the place in the file where you want the button to show up – then add this code at that location…
<a href="http://twitter.com/?status=<?php echo urlencode(the_title('','', false)) ?>+-+<?php the_permalink() ?>">Tweet This</a>
This is a super simple way of doing it – with a little more code, you can use a URL shortner to ‘shortify’ your permalink. Otherwise it might overflow the 140 char limit.
By the way, if you are on twitter, add me – I’m @binnyva