Facebook wants us to like things rather than fan or share them. I’m not, like, really liking, this change, like, you know? It makes me think of people who use like every three words they say and about passing notes in junior high. “Chris – do you think Billy likes me? Can you ask him? But don’t tell him I wanted to know.”
So, we can now add like buttons to our website. What’s cool about it is that it will show the little avatars of the people who liked your article and will post on their wall and newstream that they liked the article (if their settings allow for that).
There are two ways to add the like button in WordPress.
The code method is the first way. I would add the following to the bottom of my post in the single post page. It’s usually single.php under Appearance > Editor
<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:px"></iframe>
You can change some of the variables such as the width, change scrolling to yet, add a border, etc. Note that the url being shared is
<?php the_permalink(); ?>
That is so it pulls the specific WordPress post that is being liked. Make sure that the code added is still within the loop on the single.php page. I would put it below
<?php the_excerpt(); ?> or <?php the_content(); ?>
I have tried putting it at the top of the post but even when I set the height on the code, it pushes the beginning of the post down too far. It’s almost like (no pun intended) that it’s making room for the hoards of Facebook users who are going to be liking your post. If you’ve found workaround for this please let me know.
If you want to read more about this code or play with the fancy code generator it is available on the Facebook Developer’s Like Button Page.
You can also install the WordPress plugin called Facebook Like Button. It basically does what the code above does but there was one thing I didn’t like about it. It adds the like code everywhere and not just to posts. I might want someone to like my Services page but it doesn’t make a lot of sense to have a like button on my contact page. It is, however, super easy to set up. Just be sure to select the iframe option in the plugin settings.
So there you have it – two ways to add the Facebook like button to your WordPress site. Hope you liked it.
photo credit: found_drama