
Just yesterday, we talked about twitter releasing the official twitter button for websites and blogs. Adding twitter buttons is very easy as it involves putting a HTML code at appropriate place. As every WordPress theme is different, hence you need to find the suitable theme file and place to put that HTML code.
Today we will talk about how to do that specifically for Thesis theme. Thesis theme has got Hooks in place for customizing every bit of theme. Any customization can be done by just editing two files namely custom_functions.php and custom.css. First we will see how to do that using custom_functions.php. You need to just add the following code to your custom_functions.php.
function add_twitter_button () {
if (is_single()) { ?>
<div style="float:right; padding-left:3px;"><a href="http://twitter.com/share" data-count="vertical" data-via="avinashiitd">Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script></div>
<?php
}
}
add_action(‘thesis_hook_before_headline’,'add__twitter_button’);
Or in simple terms if you dont want to change the values like twitter ID avinashiitd to your name or you are too lazy :
function add_twitter_button () {
if (is_single()) { ?>
<div style="float:right; padding-left:3px;"> CODE GENERATED FROM TWITTER PAGE</div>
<?php
}
}
add_action(‘thesis_hook_before_headline’,'add__twitter_button’);
This will add twitter button on your posts page only. If you want the twitter button on every page including home page, then you need to remove the IF condition from the code. Ask me if you cant do that. You can edit code above to fit your needs e.g if you want the code on left side, you change the float:right to float:left.
Update :
Try the following code if you want the button everywhere instead of just Posts.
function add_twitter_button () {
{
global $post;
?>
<div style="float:right; padding-left:3px;"> CODE GENERATED FROM TWITTER PAGE</div>
<?php
}
}
add_action(‘thesis_hook_before_headline’,’add__twitter_button’);
Another way to add twitter buttons if you do not want to touch custom_functions.php, then you can use Open Hook plugin for thesis. It’s a great plugin for anyone who doesnt know how to code. You need to paste the code generated at Twitter page in the HOOK “thesis_hook_before_headline” in Open Hook plugin options.
You can grab thesis Theme here.


{ 2 comments… read them below or add one }
I can’t remove the “If” condition. It breaks my custom function file. Can you show me the exact code to remove so that the button will show up on my home page? It shows up on the all the other pages.
Thanks in advance,
Cyndi
I have updated the code as per your request. Have a look and do backup your files before trying the codes.