• Dreamhost Banner Ad

Twit This WordPress Code

I call this a Twit This WordPress Code since it’s not actually a plugin. Hehe. I got this idea after reading John Chow’s post about the Twit This Post WordPress plugin.

I like the idea. It is indeed a brilliant idea giving your readers an easy way to twit what they’ve read from your blog with a single click of a button. However, as I checked the plugin, it involves too much coding with a dependency to a 3rd party URL shortening service and involves caching of links. Eversince I learned how to shorten my post link without using those services, I never used TinyURL again on linking to my posts in Twitter. Of course, if people are going to link to my post, I don’t want them to use them either. Instead, they must use the shorter link version of my post, thus eliminating the dependency to a 3rd party service.

Since that option is not available on that plugin, I decided to create my own code. Yeah, just a code, not a plugin. Why add a plugin with so much code in it when I can simply have the same function by just adding a simple code?

Ok, here’s the code. Just add it on your single.php code, just below your post.

Just replace @marhgil with your own Twitter ID, macuha.com with your own domain name, and the img src “https://www.macuha.com/Twitter.png” with your own image link. Of course, you can modify the code as you like.

If you don’t want to have an image link, the following code will suffice:

You can see this code in action on this blog. ๐Ÿ˜‰

If you hate tinkering with codes and you don’t mind using a 3rd party service, use that plugin instead. No support will be given when using my code. Use it at your own risk, ok? Who needs support for such a short code? Hehe.

Update: John Chow is now using this code on his blog! Check his shout out here!

Update: You can also add the Twit This link on your RSS feed. Here’s how. ๐Ÿ˜‰

Update: This code is now featured on John Chow’s blog!

Update: I’ve modified the code above to insert the nofollow tag as recommended by John Chow on his post.

Marhgil Macuha

Marhgil Macuha is a Computer Engineering graduate of Batangas State University. He is currently a Senior Solutions Developer at a Canadian IT company.


  1. aba okay to ah! sinubukan ko, gumana! try ko gumawa ng code pra naman sa blogspot.d gagana un php e.

  2. may nakita na ako sa blogspot kaso dun lang pwede ilagay sa page element kasi di siya naappear kapag isinama mo un code sa template mismo. eto yun url http://twitthis.com/?type=image add mo na lang to para sa mga blogspot blogs

  3. ma try ko nga din sa blog ko

  4. Ok to matry nga. Thanks again Brother!

  5. Haha. Galing galing! Thanks sa tip marh ๐Ÿ™‚

  6. Lol i cant read any of those comments, what lanauge are those? looks like french

  7. When I install the code at first it did not work.. What I did is manually change the ( ” ) mark , I don’t know what happen since when i copied it it seems different.

    Maybe other will experience the same.. But it works now.. ๐Ÿ™‚

  8. ayos to ah, pede rin ilagay sa arcade. ๐Ÿ˜€

  9. Good job with the code snippet! Featured sa johnchow pa! ๐Ÿ˜€

  10. Uy, maraming salamat for sharing this one.

  11. nice great awesome! thanks! eaufs!

  12. Thanks for the code!

    I’ve edited this and used a nice “tweet this” button I found on the net. Check out this sample


  13. Hey thanks for the tip..

  14. Great tip! I’ll be adding it to my blog soon! More power!

  15. I just installed the code in my blog and it worked! Thanks for the code!

  16. Installed na din sa blog ko. Thanks! ๐Ÿ˜€

  17. Hi Marhgil,

    I hope you don’t mind me creating my version of “Twit This WordPress Code”.
    This uses an embedded swf file along with the dynamic link.

    See my post here: http://keywordspeak.com/2009/05/keywords-twit-this-wordpress-code/

    Nhoel of keywordspeak.com

  18. Iรขโ‚ฌโ„ขve been working from home for some time now and it really is possible to make a great income. In order to find something that is legitimate, you must first understand what you are looking for (e.g. work or business opportunity).

    Most online work requires you to have some sort of specialized technical skill sets. You should never pay to start an online job. Any site that requires you to pay to work is definitely a scam. On the other hand, if you are not technically qualified for most online jobs, then your best bet is starting your own home based business. Starting a business does require up front cost.

    The quickest way I know to make some extra cash is by selling stuff on ebay or searching craiglist for work- these are normally only short-term fixes. Iรขโ‚ฌโ„ขve tried them both and lost interest very quickly.

  19. sir..im trying to do this one but when im starting to test it and click the “Twit This”, i encountered error 404. Hope you could help me with this..thank you so much.

  20. sir..hindi po sya gumagana sa blog ko..can u help me out why..after ko ipost ung code..then nung itry ko iclick..eror 404 ang lumalabas..hayyyzzz

  21. @Crisiboy try mo copy paste muna sa notepad, then retype all the double quotes. nagkakaproblema kasi sa encoding.

Leave a Reply