Aweber - Email Marketing Made Easy
Add The New Twitter Tweet Button to Thesis Photo by: dicktay2000

Add The New Twitter Tweet Button to Thesis

August 16, 2010 · 14 comments

in Thesis

Thesis 1.x Notice: Thanks for reading this post! So, here's the deal. I wanted you to be aware that this post was written prior to the release of Thesis 2. So that means the instructions or other information provided applies specifically to Thesis 1.x and not the latest 2.x version. Thanks!

So Twitter has a cool new tweet button you can add to your blog. I’m sure there’s a bunch of plugins you could use to add it, like this one for example, but most times I prefer to add this sort of thing without a plugin. Here’s what I did to add the Twitter tweet button to my Thesis site:

Step 1: Generate your Twitter tweet button code

Visit the Twitter Tweet Button code generator on Twitter. Customize it how you’d like and simply grab the code.

Step 2: Add the code to your custom functions file

Using Thesis hooks, we’re going to add the tweet button code to the top of every post. So, this is just where I chose to put the button. Of course, you should decide where you want it and use the applicable Thesis hook. Add this code to your custom-functions.php file:

function tweet_button() {

if (is_single()) { ?>
<div class="tweet-button">
	<!--ADD YOUR CODE HERE-->
</div><!--end tweet-button-->
<?php } else { 	}
}

add_action('thesis_hook_before_headline','tweet_button');

Paste in the code you copied from the Twitter site where it says “Add your code here.” Note that the way I have this coded is that the button will only show up on single posts, not on actual pages. It wouldn’t make sense to tweet a contact page for example. If your requirements are different, you’d just have to modify the code so the button shows up where you want. Just use WordPress conditional tags for your needs.

Step 3: Add the CSS

I wrapped the code in a div with a class of “tweet-button”. This is so that I could float the button to the right, or position/style it how I want. Again, you should add your own positioning based on where you want it in your theme. This is just the way I did it, and a starting point for you to customize it. Add this to your custom.css file:

.custom .tweet-button { float:right; margin:0 0 0 15px; }

That’s it!

Pretty simple. Now click the button and tweet this post!

Was this post helpful? Consider subscribing to my blog via RSS or

This Site Runs on the Thesis WordPress Theme

Thesis Theme thumbnail

If you're someone who doesn't understand a lot of PHP, HTML, or CSS, Thesis will give you a ton of functionality without having to alter any code. For the advanced user, Thesis has incredible customization possibilities via extensive hooks and filters. And with so many design options, you can use the template over and over and never have it look like the same site.

If you're more familiar with how websites work, you can use the fantastic Thesis User's Guide and world-class support forums to make more professional customizations than you ever thought possible. The theme is not only highly customizable, but it allows me to build sites with a much more targeted focus on monetization than ever before. You can find out more about Thesis below:

{ 14 comments… read them below or add one }

Dr. Lawrence Kindo August 17, 2010 at 11:13 am

The twitter buttons are absolutely fabulous. I like this tutorial – a much needed one. I have been using tweetmeme, I think it would be a good idea to switch over directly to twitter’s buttons.
Dr. Lawrence Kindo recently posted..Why I Decided to Enter a Blogging Contest

Reply

Ari Herzog August 21, 2010 at 12:58 pm

Thanks for sharing your custom function which enabled me to do that which other functions’ codes failed. Appreciated!

What does it mean, though, if I click the tweet button and send a tweet, the box count says 1, I refresh the page, and the count goes back to 0?
Ari Herzog recently posted..Help Me Find My Next Job

Reply

Thesis-Blogs.com August 21, 2010 at 3:39 pm

Hi Ari… thanks for commenting. The only reason I can think of that the twitter counter will get reset to zero, may have something to do with the permalink of the post. I believe the script counts the tweets based on the permalink URL. If that changes between tweets, it will not pick up the previous count. Not sure if you did anything along these lines.

Reply

Christophe August 26, 2010 at 4:58 pm

Dear,

I have tried the code but I never displayed the Twitter… I’m looking for 2 weeks now how to put the FB Like + Twitter Official like you (close to the title on my Thesis).

Your help will be more than mandatory!

Many thanks in advance,

Christophe

Reply

Christophe August 26, 2010 at 5:14 pm

Fixed :)

Reply

Dj Trinity October 8, 2010 at 8:33 pm

its working, but tweetmeme plugin is easy to use.
Dj Trinity recently posted..Behringer BCD2000 review &amp Mapper for Virtual DJ 60

Reply

Gustavo January 21, 2011 at 10:50 am

How can I put the buttons to float/align to the right of the headline?

Reply

Thesis-Blogs.com January 21, 2011 at 10:57 am

Thanks for commenting. Did you try Step 3 above? That will float the button to the right.

Reply

Gustavo January 24, 2011 at 8:47 am

Yeah I was able to pull it through. The problem I had is that I was trying to add 4 buttons. But I managed to pull through it.

Reply

naharazizi July 5, 2011 at 7:51 am

this’s cool.. thank so much for your share. it so help me to desaign.

Reply

Sorin September 12, 2011 at 12:47 am

hey guys,

i have a problem with custom.css, everthing i add in this file don’t work like don t have permision..what can be?
Sorin recently posted..Am iubit, mesaje pentru iubit

Reply

Thesis-Blogs.com September 12, 2011 at 6:20 am

In Thesis site options, make sure the custom stylesheet option is enabled.

Reply

jayson August 21, 2012 at 11:44 pm

what if I want to implement this on my home page only, not on a single post page :)
jayson recently posted..Interview with Mike Essex of Koozai – The Art of Giving Away Free Stuff

Reply

Thesis-Blogs.com August 22, 2012 at 8:52 am

Change 'is_single' in the code to 'is_home'.

Reply

Leave a Comment

When commenting, you can use basic HTML tags. If you are pasting in any code, please escape it here and then include that code within <pre></pre> tags. Thanks!

CommentLuv badge

Previous post:

Next post: