Post Pic

WordPress tip: Create a Tweetmeme “Retweeet” shortcode

Tweetmeme is a popular service that allow you to display “Retweet” button on your blog posts. Even if the code is easy to integrate on your single.php file, it can be very cool to create a shortcode that you can insert anywhere in your posts.

Paste the following code in your functions.php file in order to create the shortcode:

function tweetmeme(){
	return '<div class="tweetmeme"><script type="text/javascript" src="http://tweetmeme.com/i/scripts/button.js"></script></div>';
}
add_shortcode('tweet', 'tweetmeme');

Once done, you can display the Tweetmeme "retweet" button anywhere on your posts. In WordPress editor, make sure you are in HTML mode and insert the following:

[tweet]

When your post will be published, the shortcode will be replaced by the TweetMeme button.

17 Responses

Oct 14 2009 10:11

Is there anyway to not have the reply have @tweetmeme in it?

Oct 14 2009 10:57

Is this the same retweet button you are using?

I’ve been trying to find a solution that doesn’t require linkage to tweetmeme and only posts to twitter. Also would like the ability to customize the button.

Oct 14 2009 12:48

Can be a problem if you already have the tweetmeme plugin. I had to rename the function tweetmymeme() :)

Thanks anyway.

Oct 14 2009 14:40

Personally I would not encourage this method since you will have a lot of [tweet] in your posts when you finally decide to remove this plugin. Twitter will not be a success forever and then it might be a good idea to remove all plugin related to it.

Instead I would recommend people to add this plugin to their theme.

Oct 14 2009 15:30

@Stefan

You and I know Twitter is a hot thing that’ll fade like the internets of old, but there are clients and social media marketers that would insist on this sort of functionality on each post. Personally, I prefer the “share” link, no need to double dip, but retweet is popular now.

Oct 14 2009 22:48

@Branden Silva : yes it is the same, but mine is hardcoded in my theme. If you visit one of my other blogs, this is exactly that method that I implemented on there.

@Stefan : “I recommend using this plugin”…WpRecipes is, since its creation, a WORDPRESS HACKS sites. It have nothing to do with plugins.

Dec 18 2009 16:55

How to include RT@myusername in when you use this plugin. Thank You.

Dec 18 2009 21:39
Dec 26 2009 02:03

hey how can I add this button to my theme to get the same result? probably adjacent to the title post the RT button will look quite observable to my readers.

Jan 11 2010 00:08

Can a custom hastag be added to every tweet by modiying the core code of tweetmeme plugin?

Trackbacks:

Leave a Comment

* Name, Email, Comment are Required