How to add the Facebook Like button to your theme

It's been a while since I wrote a post here on my blog. I have been busy lately with some personal projects.

Let's get started. With the increasing popularity of Facebook social plugins, such as the Like button, many people wonder how to add the Like button to their theme. In this quick tutorial, I will show you how to add it in your Zen theme.

1. Open your Zen theme folder and locate the node.tpl.php. I am using version 2.0 of Zen, and I have my themes saved at sites/all/themes/zen/templates/

2. Once you find the template, find the following code
<?php print $links; ?>
Add the following, right below it(Type it!):
Like button
Replace example with your domain.

3. Now open your page.tpl.php template, it should be at the same location where the node.tpl.php, and add this in the HTML tag of your template:
xmlns:fb="http://www.facebook.com/2008/fbml
It should look like this
Facebook

4. Upload your page.tpl.php and your node.tpl.php to your server. Make sure you clear your cache, it's at site configuration / Performance / Clear cached data.

You will need to register your website on Facebook in order for the Faceook Like button to work. For Internet Explorer to show the Like button, you must complete step 3.

If you complete all the steps above, the Facebook Like button will show on every node in your Zen theme. A working example is here at Latino themed events.

Comments

Add new comment