Home » Internet » Blogging » How to use the FaceBook Like button with WordPress Thesis theme

How to use the FaceBook Like button with WordPress Thesis theme

Would you like to use the latest FaceBook Like button with your WordPress Thesis theme? Although there are multiple FaceBook Like button plugins available, it’s good to be able to tweak the source code, especially when you are using the friendly WordPress Thesis theme.

Unlike putting the FaceBook Like button on a regular WordPress theme, in Thesis there is no need to change the single.php source code. All you have to do is add a new hook. Wondering what a Thesis hook is? Here’s a good reference

Hooks are basically functions that you add to the various portions of your blog. For example, the FaceBook Like button code will go into a hook that handles stuff that occurs after the blog post, after the text, but before the comments.

The WordPress Thesis hooks are edited in a file called custom_functions.php and this file resides in the custom folder of your active Thesis theme. So open your custom_functions.php file and add the following code:

function facebook_like_button()
                <iframe src=”http://www.facebook.com/plugins/like.php?href=<?php the_permalink() ?>&layout=standard&show_faces=true&width=450&action=like&colorscheme=light” scrolling=”no” frameborder=”0″ allowTransparency=”true” style=”border:none; overflow:hidden; width:450px; height:60px”></iframe>

As you can see, is_single() takes care that the core activates only when a single post is being displayed. After creating the hook, you need to add this to the Thesis hook collection. For that, you need the following command:

add_action(‘thesis_hook_after_post’, ‘facebook_like_button’);

That’s it.