How to add a Facebook Like button on my website?

Simply go to developers.facebook.com/docs/reference/plugins/like¬†and follow the very intuitive and user friendly Like button “wizzard”. After selecting your option it will generate a code similar to the one below:<iframe src=”http://www.facebook.com/plugins/like.php?href=www.test.com&amp;layout=button_count&amp;show_faces=false&amp;width=450&amp;action=like&amp;colorscheme=light&amp;height=21” scrolling=”no” frameborder=”0″ style=”border:none; overflow:hidden; width:450px; height:21px;” allowTransparency=”true”></iframe>The only problem is that this will enable visitors to just Like the URL (usually the link to your homepage) that you have entered in the “wizzard”. If you want the Like button to reflect the URL of a particular page that they are on, then you have to do a bit of programming.It’s not hard, here is how you do it in PHP:Replace the URL which follows after “href” (in this case www.test.com) with the following code:<?php echo urlencode(“http://”.$_SERVER[“SERVER_NAME”].$_SERVER[“REQUEST_URI“]); ?>Copy/paste it in the file you wish to display your Facebook Like button. Make sure it is a php file.

2 thoughts on “How to add a Facebook Like button on my website?”

Comments are closed.