How to: Create a “send this to twitter” button

Some times ago, I shown you how to display your last twitter entry on your WordPress blog. Today, let’s create a button to allow your visitors to send the current post they’re reading to twitter.

Nothing hard with this recipe: Simply paste the following code on your single.php file, within the loop:

<a href="http://twitter.com/home?status=Currently reading <?php the_permalink(); ?>" title="Click to send this page to Twitter!" target="_blank">Share on Twitter</a>

Your readers are now able to send your post url to twitter! Hope it will bring you some traffic and new readers!

Thanks to BabyGotMac for letting me know about this nice code!

3 Responses

Aug 06 2012 13:42

nice.
but an iframe is a better solutioin:

<iframe allowtransparency="true" frameborder="0" scrolling="no" src="http://platform.twitter.com/widgets/tweet_button.html?url=&via=xtapit&text=” style=”width:115px; height:21px;”>

Aug 13 2012 05:28

Nice code! But you’d want to put %20 for the spaces in the link, just to make sure the text came out alright.

Oct 20 2012 13:19

Nice code! But you’d want to put %20 for the spaces in the link, just to make sure the text came out alright.

Trackbacks:

Leave a Comment

* Name, Email, Comment are Required

WP Theme of the week

Sponsored Likebox