Blogging

How to create your own ReTweet Button and Short URLs for WordPress Blog?

I was using tweetmeme wordpress plugin to create a retweet button for my posts. The most annoying feature of that button was that when you click on the button it would Re-Tweet your blog post (Title + Shortened URL) using their own Twitter Id i.e. “RT @tweetmeme <message>”. So, its like all the credit for your post goes to @tweetmeme and your popularity doesn’t seems to increase much.

While searching for alternatives I came across a very simple and useful way to create your very own ReTweet button and your own version of URL shortener.

Step 1) Create your own shortened URL for your blog entries:

For WordPress, create a folder within the root of your domain/blog (here http://bawaal.com/blog/). Name the folder “go”, or something equally short. Then make a .htaccess file in the newly created directory and include the following code:

RewriteEngine On
RewriteRule ([0-9]+) /index.php?p=$1 [R=301,L]
RewriteRule (.*) / [R=301,L]

Note: Windows may not allow you to create a file names “.htaccess” so you can create any text file in your local machine e.g. “temp.txt” using notepad and copy the above code into it. Transfer this file to newly created directory [“go”] on your blog server and rename it to .htaccess

Step 2) Create Re-Tweet Button:
You can use an image or a text to create a hyperlink to ReTweet your post. Below is the code I use for my posts:

<a href=”http://twitter.com/home?status=RT @shankybaba <?php
the_title(); ?> – <?php echo get_bloginfo (‘url’);
?>/go/<?php echo $post->ID ?>”><img src=”/files/retweet-btn.jpg”/></a>

All you have to do is to replace “@shankybaba” with your “@twitterid” and if you named your directory containing .htaccess file something else than “go” and use that name in the above code.

Step 3) Add the above URL code to your WordPress template:

Single Post (single.php): For the retweet button to appear on post single pages.

In this blog site I have placed the below code to appear alongwith the title of the post:

<h2><?php the_title(); ?><a href=”http://twitter.com/home?status=RT @shankybaba <?php the_title(); ?> – <?php echo get_bloginfo (‘url’); ?>/go/<?php echo $post->ID ?>”><img src=”/files/retweet-btn.jpg”/></a></h2>

Main Page (index.php): For the retweet button to appear on the main page along with each posts.

In this blog site I have placed the below code just after the comments code for each post:
<a href=”http://twitter.com/home?status=RT @shankybaba <?php the_title(); ?> – <?php echo get_bloginfo (‘url’); ?>/go/<?php echo $post->ID ?>”><img src=”/files/retweet-btn.jpg”/></a>

Benefits of using this method:

  • You have full control over the ReTweet ID (instead of @tweetmeme)
  • The most important thing is that all the URL now includes your domain name unlike tinyurl or bit.ly
  • Web crawlers (for any search engine) won’t able to comprehend shortened url like [bit.ly] or [tinyurl]
  • Using 3rd party shortened URL unjustifyably denies the visibility of your domain name which can deprive your domain the popularity you expected.

Popularity: 1% [?]

Discussion

4 comments for “How to create your own ReTweet Button and Short URLs for WordPress Blog?”

Ads by Google

On Facebook

Bawaal on Facebook