Add FB Like box to WP


Officially you can apply settings for a like box for facebook from this link – https://developers.facebook.com/docs/reference/plugins/like-box/ – download the code and set it up on your site. the above link works if you have one URL that you want to use the box with.

but what if in wordpress we want to add the likebox to all pages and posts dynamically without specifially adding a plugin and then modifying it to show at a particular place in the post.

we have an easy solution. Here wordpress template tags come to work. you can download the code snippet from facebook website and alter it. then you can put it in your wordpress template single.php and/or page.php for facebook like box to show with dynamic url.

here is the code. please double click and copy/paste the below code and voila!

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

wasn’t that an easy solution?!

Leave a Reply

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