How to Add Facebook Like Button to WordPress and Thesis Website

Earlier this week Facebook added some features to make the web experience even more social. Saw a post on How to Add the Facebook Like Button to Hybrid by Patrick Daly so I thought I’d add this to my WordPress sites.

To install it on to WordPress, add this code to the single.php file

<iframe src="http://www.facebook.com/plugins/like.php?href=<?php echo urlencode(get_permalink($post->ID)); ?>&amp;layout=standard&amp;show_faces=true&amp;width=450&amp;action=like&amp;font=verdana&amp;colorscheme=light" scrolling="no" frameborder="0" allowTransparency="true" style="border:none; overflow:hidden; width:450px; height:px"></iframe>

To install it on a Thesis Theme WordPress site, you need to have the Thesis OpenHooks plugin installed. Add this code in the After Post box on OpenHooks. Make sure you to include the php code if you want it to just show up after your blog posts. Adding just the <iframe> code would show the Facebook Like button on every page.

<?php if (is_single()) { ?>
<iframe src="http://www.facebook.com/plugins/like.php?href=<?php echo urlencode(get_permalink($post->ID)); ?>&amp;layout=standard&amp;show_faces=true&amp;width=450&amp;action=like&amp;font=verdana&amp;colorscheme=light" scrolling="no" frameborder="0" allowTransparency="true" style="border:none; overflow:hidden; width:450px; height:px"></iframe>
<?php } ?>

One Response to How to Add Facebook Like Button to WordPress and Thesis Website

  1. PlF

    Here’s the WordPress plugin:
    http://wordpress.org/extend/plugins/like
    No coding necessary, you can customize the look and placement of the button in the settings interface

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>