I’ve received quite a few emails asking how I modified the Tweet This WordPress plugin to make it performed the way that I wanted. I was going to write a little tutorial on it but then @Marhgil over at Macuha.com informed me that I could have created the Tweet This link without a plugin.
Because I only wanted to insert the Tweet This link at the bottom of my posts and didn’t needed any of the other features the Tweet This plugin offered, it would just be a simple matter of adding one line of code to the single.php file. Marhgil explained how he did it here. I made a couple changes to clean up the codes a little.
<a rel=”nofollow” href=”http://twitter.com/home/?status=Reading @JohnChow – <?php the_title(); ?> https://johnchow.com/?p=<?php the_ID(); ?>”><img src=”https://johnchow.com/images/tweet-this.png” alt=”Tweet This” /> <strong>Tweet This Post!</strong></a>
Insert the above code (change to your domain and twitter name) to your WordPress single.php file at the point where you want the Tweet This link to show up. In my case, I have it appear right after the post.
You will noticed that the link uses the default WordPress URL structure of https://johnchow.com/?p=xxxx instead of the SEO friendly URL. Doing it this way will allow you to bypass the use of an URL shorten service. JohnChow.com only has one more letter than TinyURL.com so this isn’t a big deal. What is a big deal is the URL has my domain name in it and reinforces my brand. You can save yourself a few letters by using www instead of http:// as Twitter.com will auto link the URL. However, Twitter clients like TweetDeck will not link the URL if it’s missing the http:// so I recommend you stick with it.
You won’t have to worry about readers getting to your blog using the default URL because WordPress will auto forward them to the SEO friendly URL. I added a ref=nofollow tag to ensure that no Google juice is passed to the short URL.
The advantage of using a line of code instead of a plugin is less overhead. A simple line of code consume less resources than an entire WordPress plugin so your blog should run faster. The other advantage is using your own domain in the short URL to help reinforce your brand.