Add Tweet Button to Each Post

Applies to Version(s): Thesis 1

Place the following code in custom_functions.php (remember to replace diythemes with your own Twitter username!!):

function twitter_button() {
if (is_single()) { ?>
   <div class="tweetbutton">
      <a href="http://twitter.com/share" class="twitter-share-button" data-count="vertical" data-via="diythemes">Tweet</a>
      <script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script>
   </div>
<?php }
}

add_action('thesis_hook_before_headline', 'twitter_button');

Place the following code in custom.css, adjusting as necessary to accommodate your site’s design:

.custom div.tweetbutton {
	float:right; 
	padding-left: 5px;
}

On Pages Where Multiple Posts are Listed

If you’re trying to add the Tweet Button to a page where multiple posts are listed, the Share Button link must include a reference to the necessary permalink for the respective post; so you’d use this version of the PHP code above instead:

function twitter_button() { ?>
   <div class="tweetbutton">
      <a href="http://twitter.com/share" class="twitter-share-button" data-count="vertical" data-text="<?php the_title(); ?>" data-url="<?php the_permalink(); ?>" data-via="diythemes">Tweet</a>
      <script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script>
   </div>
<?php }

add_action('thesis_hook_before_headline', 'twitter_button');

Reference: Tweet Button Documentation from Twitter.com