There are two ways to get a “Tweet this” button on your site:
1. The easy way: by setting some options and having Twitter generate a code snippet which you can insert on your page. The code will create an iframe with a default Tweet button.
2. The hard way: by using query string parameters, which allow you to use your own styling on the button.
There are a few articles out there with in depth explanation of how to use the query string parameters, but if you are looking for a simple easy to use code snippet to use in your WordPress site, here it is:
echo"<div id='custom-tweet-button'>"; $twitter_href = 'http://twitter.com/share?url=' . get_permalink(); $twitter_href .= '&text=' . get_the_title(); echo"<a title='".get_the_title()."' href='".$twitter_href."'>Tweet</a>"; echo'</div>';
You can paste this anywhere in your page.php or post.php e.a. It will give you a link that can be clicked to share the page on Twitter. After that, the link can easily be styled with a background image:
#custom-tweet-button a { background: transparent url(you-twitter-image.png) no-repeat 0 0; display: block; width:22px; height:20px; text-indent:-9999px; }
It’s also possible to create a custom Facebook Like button.