In this very short article I am going to show you how to implement a TweetMeme badge to your website. This is a great way to encourage your visitors to re-tweet your story. You might want to implement it to your WordPress or non WordPress website. I’ll show both ways of getting a TweetMeme badge.
TweetMeme is a service that puts all the popular links on Twitter together in one place to determine which links are popular. Then it takes these links and categorises them in order to filter out what you are interested in. You can find out more on TweetMeme.
The button provides a URL and the title of the story or page. Every single link that is posted on Twitter adds one to the tweet count of the story. So this TweetMeme button (badge) can be a very good idea to remind to your visitors to re-tweet your story. TweetMeme website describes an implementation processes but they did´t work for me, so I decided to write about custom implementation. So, let´s crack on!
You will need to include this php function at the end of your functions.php file. If you are not using a WordPress and don’t have a functions.php file, just simply paste it as a php code on a page before any header request.
If you are not using WordPress, you need to get the current page url and replace with it. Read my post on How to get the current page url.
If you want to add your twitter id to visitors re-tweet, next to the url, you need to add one more line just after the tweetmeme_url in our code.
Now you have got a few choices depending on what you want to do. You might want to show the badges on every single post, if this is the case just locate your posts template (index.php or single.php for WordPress) and echo the function just before the or . If your website is non WordPress just echo this function where you want your badge to be displayed.
If you want to display in on some of the posts only and you would like to have a full control on what post the badge is displayed you might want to you custom fields on WordPress. If this is the case, instead of echoing the function we can check if the custom field was defined and if it was then echo the function. See the code below:
Now create a custom field on the post called TweetMeme and set the value to true. The badge will only be displayed on posts containing this custom field. Enjoy!
Latest Tweets
Partners
Resources
Become a Guest Author
About the Blog Author