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, with your own domain name, and the img src “” 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 Engineer by profession. He is a professional network marketer in the Philippines, with business partners all over the world.

Facebook Comments

Leave a Reply