Thesis and the Facebook Like Plugin

One of the best ways of promoting your blogs is via Facebook integration. There are a number of ways of achieving this, but I’ve found that the most organic and least intrusive way of promoting a single post is the Facebook like button (not unlike posting a link to your Twitter stream). It isn’t associated with a fan page, but simply renders an entry into your Facebook stream that states you like a particular post on a particular website. It’s a great way of sharing content with friends.

Facebook Like text as it will appear on your site

Facebook Like text as it will appear on your site

Although there are a stack of WordPress plugins that will accomplish what I’m about to show you, these plugins won’t take advantage of the excellent Thesis hook framework (so will invariably compromise on load time). If you do go the way of a plugin I suggest fblikebutton. It’s the easiest to use and most compatable with Thesis.

Facebook make the process a piece of cake. From their development site, you can simply enter a few details and they’ll give you code that you can post onto an individual page. What I’m going to do here is show you how to use Thesis hooks to place the Facebook like content anywhere the framework’s hooks permit. When a user clicks the ‘like’ button it will send details of your post and website to the users Facebook page.

Facebook user stream

Facebook user stream

The most likely spot you will want the like button is after a post (Hook: thesis_hook_after_post).

Like button at end of post

Like button at end of post

Navigate your way to wp-content/themes/thesis/custom and open up custom_functions.php for editing. Add these lines at the end of the page.

/* Facebook Plugin */
function add_fb_like () {
if (is_single()) {
?>
<?php
echo ''
?>
<?php
}
}
add_action('thesis_hook_after_post', 'add_fb_like');

There are a number of parameters you can change, most notably the width and height of the Facebook iframe.

If you’re not overly comfortable using hooks, you can accomplish the same result using the Open Hook plugin.

Select Open Hook from your WordPress menu, browse to the hook After Post option and paste the following code inside of the text box. Be sure to click the option “Execute PHP on this hook”. Save and exit.

<?php
echo ''
?>
Thesis 'Open Hook'

Thesis 'Open Hook'

I’ve just started tracking the effect a Facebook like button has on the popularity of posts. I’ll post the results to this site.

First Name:
Your Email Address:
 


If you liked this article, you may also like:

  1. Thesis and Yet Another Featured Posts Plugin (YAFPP)
  2. Adding New Widget Areas in Thesis
  3. Add a Facebook Like Box to WordPress (with and without Shortcode)
  4. Add a Facebook Follow/Subscribe Button to Your WordPress Website with Shortcode
  5. Embed Facebook Posts into Your WordPress Post or Page with Shortcode
About Marty

is a passionate web developer from Sydney, Australia. He owns about 600 websites and makes a healthy living from working the web. As a day job, he works as a pilot for an international airline. Follow Marty on Twitter or Google+.

Comments

  1. Karen Miles says:

    Thank you. I tried a few Facebook plugins and when none worked I was going to give up. Google search… internoetics… and my answer. Worked just as promised.

Please leave a comment or question!

*