Custom “Tweet This” Link
by walter on Dec.21, 2009, under Blogging
Visited 1576 times, 7 so far today
I wanted to try to put a “tweet this” icon after each post, but didn’t really want to bother with another plugin to do it, so after a little research I came up with my own. Adding a Facebook icon was similar.
The basic format for Twitter is this.
<br/><a href="http://twitter.com/home?status=Title of Post http://URL_of_post"><img src="twitter_icon.png" alt="Tweet This" /></a>
You can automate the title of the post and the URL like this.
<br/><a href="http://twitter.com/home?status=<?php the_title(); ?> <?php the_permalink() ?>"><img src="twitter_icon.png" alt="Tweet This" /></a>
And in my case where I’m using the YOURLS plugin to generate short URLs, I can further automate the URL to be the short URL.
<br/><a href="http://twitter.com/home?status=<?php the_title(); ?> <?wp_ozh_yourls_raw_url(true); ?>"><img src="twitter_icon.png" alt="Tweet This" /></a>
Place that in your single post and/or page template and it will send the user to twitter where they’ll be asked to log in, and then the post title and short url are prepositioned for them. Of course, you’ll also need to adjust the icon filename as needed for your specific case.
See Facebook instructions, next page
Pages: 1 2
:How To, wordpress