Twitter has officially released the twitter tweet buttons for its users. Most of the users already started using these buttons now. In my last post I shared a tutorial to add official tweet buttons to WordPress blogs. Now I’m going to share a tutorial for adding a tweet button to thesis WordPress theme.
How To Add Tweet Button To Thesis
- First copy the following code and replace tricksdaddy with your own twitter user name.
function offical_tweet_btn() {if (is_single()){ ?> <div style="float:right; padding:4px;"> <a href="http://twitter.com/share" class="twitter-share-button" data-count="vertical" data-via="tricksdaddy">Tweet</a> <script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script> </div> <?php }} add_action('thesis_hook_before_post', 'offical_tweet_btn');
- Now navigate to your custom_functions.php file and paste the code there.
Note: Take a backup of your custom_functions.php file before making any changes to it. - Now save your custom_functions.php file and refresh your blog. You will see new official tweet button on your blog.
Customization
If you want the button to appear on left hand side then simply replace float:right with float:left
Twitter tweet button is available in following three styles:
You can have any of the following styles on your blog. If you want to show your button in horizontal or no count style, then simply replace vertical with horizontal for horizontal style button and none for no count button.
If you are not using thesis, you can get thesis now.
Hello! Thanks for your post. What if you also want the button to appear on each of the posts displayed on the homepage in addition to each single post?
Thanks!
Diana
@dianafreedman
If you want the button to appear on homepage also then you can use the following code:
function offical_tweet_btn() {
?>
<div style="float:right; padding:4px;">
<a href="http://twitter.com/share" class="twitter-share-button" data-count="vertical" data-via="tricksdaddy">Tweet</a>
<script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script>
</div>
<?php
}
add_action(‘thesis_hook_before_post’, ‘offical_tweet_btn’);
Hey Simrandeep,
Great post. Very Useful.
Thanks for sharing the code. Keep up the good work.
Great post and useful
You’re good at thesis customizing. I tried and don’t know anything.
I’m using the tweetmeme button on my blog, but I’m using a function. I find it better to use a function than install another plugin. You have made this very easy for others to do the same and that’s cool.
You could modify the code to not work on category pages as well.
You are right George, its not a good idea to use another plugin to add just a single Retweet button. Its better to use function for such purpose.
BTW thanks for the suggestion George. I’ll modify it as suggested by you.
Cheers 🙂
I saw this new release in the WP latest plugins bar , yet to use it. But most of my readers are facebook users , and not twitter users . So u have to see if its worthy of using it .
great tip for thesis users….
Great article, very straightforward and easy to understand.
Works perfectly, thanks very much 🙂
Great post. Very Useful.
Thanks for sharing the code. Keep up the good work.