Site icon Anirban Saha

Facebook like button function using php

The wordpress plugin with the name “Facebook-Like-Button-Widget.zip” is not working properly.

The problem :

The entire content of the blog post is being replaced by the facebook “like” button.

It was not visible in the index blog page, although it was visible in the single blog post pages, for the particular blog post.

Solution:

I wrote a function to remove the problem.

go to index.php of the wordpress theme folder.

search for “<h2>…..</h2>” After that put in

<?php

$fb_anirban_link=get_permalink();

fb_anirban_like($fb_anirban_link);

?>

go to the single.php of the wordpress theme folder

search for <h2><?php the_title(); ?></h2> and put in

<?php

$fb_anirban_link=get_permalink();

fb_anirban_like($fb_anirban_link);

?>

Go to functions.php

and just before the “?>” tag put

function fb_anirban_like($fb_anirban_link)

{

$anirbanvalue=$fb_anirban_link;

$anirban1= rawurlencode($anirbanvalue);

$anirban1=$anirban1.”&amp”;

echo “<iframe src=’http://www.facebook.com/plugins/like.php?href=$anirban1;

layout=standard&show_faces=true&width=450&action=like&colorscheme=light&height=80′ scrolling=’no’ frameborder=’0′ style=’border:none; overflow:hidden; width:450px; height:80px;’ allowTransparency=’true’></iframe>”;

Make sure:

that you add “&amp” to the end of the encoded url.

and now it is working properly. Replace the “%24anirban1″with “**dollar*anirban1”

Exit mobile version