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!

79 Responses

Nov 06 2008 11:41

Many thanks Jean:)

Nov 06 2008 12:42

You’re welcome :)

Nov 06 2008 13:43

Thanks!

Nov 06 2008 13:45

Hi,
I wrote about your website on my blog, http://www.blogatoire.com
i find it very useful for all WP users.
Many thanks

Nov 06 2008 21:19

Thanks! Just registered at twitter recently. :) Shall try this at my blog.

Nov 06 2008 21:29

@Rarst: Hope you’ll enjoy Twitter :) You should follow me ;)

Nov 06 2008 22:04

@jbj

Done! :)

Nov 07 2008 03:51

Hi, Jean:

Where (within the loop) does the code go? Can you be a tad more specific for the code challenged in the room. (like me) LoL.

Nov 07 2008 07:52

Hello Missy,
On single.php, you can paste this code anywhere within the loop. For exemple, you should paste it below the_title();

Nov 08 2008 14:04

That’s a great idea to make use of twitter. Thanks for the share. Hopefully this brings in additional targeted traffic as well as a few more followers for twitter.

Wei Liang

Nov 09 2008 11:02

Thanks for this… It’s simple, but fun.

Jan 07 2009 23:27

Was just thinking there needs to be a plug in for this! I’ll take the code snippet in the meantime . . . thanks so much!!! (PS – love your cat!!)

Jan 07 2009 23:49

Thank you for this nifty piece of coding. I included an image to make it a button and it works superbly!

Jan 08 2009 00:18

@faryl & @saaleha: Thank you =^.^=

Jan 08 2009 16:03

Great, just putting this on my blog now :)

That’s ideal, I think we’ll be adding that to our blog.
p.s. I love the way your cat avatar looks up at the person you’re talking to!

Jan 08 2009 19:48

Wow, that was easy. And I can see how easy it is to add a twitter logo or some other fling to make the button more noticeable.

Thanks!

Jan 09 2009 22:17

oh, this is nice… Thanks

Jan 10 2009 00:34

think i will be sharing this one round. A really neat piece of code and so simple. Going to use it on my blog.

Jan 10 2009 03:14

Thanks dear..this is sweet.helpful

Jan 17 2009 17:30

thank you very much.

Jan 19 2009 22:01

This is pretty cool. I just used it in one of the designs I’m making. Thanks.

Jan 26 2009 15:22

Thanks!!

Feb 12 2009 02:46

Thanks for the great tip. I’ll put it on my articles.

Feb 12 2009 19:40

Awesome – worked like a charm.
Thank you!

Feb 26 2009 18:05

Hello
I not sure if you will be able to help me with this but you seem the person to ask. Is it possible to have a twitter feed as part of a website? If any one has experience with twitter feeds any, info would be gratefully appreciated.

Feb 27 2009 00:21

@Anna Green: Sure, you can create a page template with your twitter feed :)

Mar 04 2009 18:58

How do I go about it, is it similar to Wordpress? Is there any software I need to download or do I just apply a news feed? Im really excited by the idea of a daily news feed that is connected to my twitter account. But there doesn’t seem to be a tutorial anywhere!

Mar 06 2009 20:28

Great stuff, thanks for this! Great blog btw!

Mar 26 2009 18:38

wow… thank u so much. I need it.

Apr 22 2009 17:47

I am having interesting issue with this snippet. Trying to include hashtag in tweet and it completely stops working. Tries to open profile with name equal to hashtag instead. I don’t think # has encoded equivalent.

Any ideas?..

Jun 17 2009 03:16

add a small icon instead of text and should be better. Cheers!

Jun 22 2009 18:50

Nice stuff. Thanks, really need this, especially on start of my new blog.

Sep 12 2009 17:11

Just what I need for my new blog. Thanks buddy.

Sep 17 2009 02:57

Having a hard time with this. “your single.php file, within the loop:”
I am pretty savvy with code but I have no idea what this refers to.

I saw where you directed somebody to: “On single.php, you can paste this code anywhere within the loop. For exemple, you should paste it below the_title();”

Can you be even more specific? Where am I finding this file at? Sorry if I’m a complete newbie.

Sep 17 2009 09:16

@Tony Hurst : Google “WordPress loop” and you’ll find out. Good luck!

Sep 17 2009 09:34

Thank you. The confusion is that I’m using Wordpress.com and not Wordpress.org and it appears that I don’t have access to the files through the WP.com interface. The result of your suggestion of googling that made that clear.

This will make Wordpress.com quickly irrelevant for me as it appears that technology and user desire is outpacing the interface.
Thank you so much. -Tony

Oct 13 2009 23:32

We have been looking for tools like this to integrate our social media efforts. Thank you.

Trackbacks:

Leave a Comment

* Name, Email, Comment are Required