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.
The Code
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
I think most of them would need a url shortner, hmm I would need anyway. My permalinks are kilometres long.. lol
This vacation I am gonna kill most of my plugins, will add this one too.. If I cant integrate the url thingy (I learnt the u.nu ‘s api recently) I might pounce on you.. 😛 lol
Good job Binny, there again 🙂
Wow that’s a nice bot of information.. will surely try it out! =)
You sure are helping users optimize their WordPress installations 😀
Thanks guys!
I use a plugin .. that was easier .. but not sure if that adds additional mysql db load..
how to find the single.php file in the theme? I m using the MOTION theme(wordpress official themes)!! guide me please!