06
May
2010
2010
Add “Tweet This Post” link in WordPress

There are few very good WordPress plugins which add a twitter like icon and link to tweet the post. But instead of using plugin, I will show you how easily you can add a link to “Tweet this post” in your WordPress blog.
You can use below code to add a link to tweet a post.
<a href="http://twitter.com/home?status=RT @techyag <?php the_title ();?> <?php echo get_settings('home'); ?>/?p=<?php the_ID(); ?>" target="_blank">Tweet This Post!!</a>
In above code, change techyag to your twitter username. When this link is clicked, visitor will be taken to twitter site and will get something like this:

Lets go ahead and add a twitter icon instead of text link. Upload a small twitter icon names twitter.png in images folder of theme you are using. If you are using default WordPress theme, upload twitter icon in “wp-content\themes\default\images” folder. And use below code.
<a href="http://twitter.com/home?status=RT @techyag <?php the_title ();?> <?php echo get_settings('home'); ?>/?p=<?php the_ID(); ?>" target="_blank"><img src="<?php bloginfo('template_directory'); ?>/images/twitter.png" border="0" /></a>




You really found a way to make this whole process esiear.