Facebook Send Button + Individual WordPress Posts
So, you’ve heard about the newest Facebook launch, the Send Button, and now you want to get it for your site.
You go to the Facebook Social Plugins Developer site, fill in your info, and wahlah you’ve got the code to implement your very own Facebook Send Button. Everything is hunky-dory, right?
Well, kind of. Depending on you what you want to be able to send. If you want the same url to be sent every time someone hits that button, then yes. You are good to go.
However, if you’re looking for a way to make it so that individual posts are sent each time someone clicks that button, read on. We’ve got the 411.
First of all, you want to make sure that you’re getting the code JUST FOR the send button. Yes, Facebook states that you can “add on” the send function to your existing Like button but during testing, we found that the code would either display incorrect numbers or send the generic URL. Not what we want.
Anyway, the code you get (depending on the options you’ve selected from Facebook), will look something like this (I’ve put in extra spaces so make sure to take those out if you’re copying this directly):
< script src=”http://connect.facebook.net/en_US/all.js#xfbml=1″ >< /script>< fb:send href=”YOURWEBSITEHERE” font=”arial” >< /fb:send >
All you need to do (yes, it really is this simple) is remove YOURWEBSITEHERE and replace it with
< ?php the_permalink(); ? >
(again, if you’re copying this, I added extra spaces into that code so make sure to remove them)
In the end, your script will look like this:
< script src=”http://connect.facebook.net/en_US/all.js#xfbml=1″ >< /script>< fb:send href=”< ?php the_permalink(); ? >” font=”” >< /fb:send>
And that’s it. Now you just have to decide where you want it. I put mine in the main loop file (loop.php) but it will work elsewhere too.
Now, go forth and have fun with your new Facebook Send Button!