Facebook announced a ton of new technology at their F8 Developers Conference yesterday in San Francisco. At the conference they unveiled a ton of new technologies that I think could reshape the web.
This is a “gloves off” move between Facebook and Google. Facebook is claiming they have a better way of determining the relevance of web pages, based on social interactions online rather than by ranking pages based on back links. They call it the Open Graph.
Facebook for Websites
There are a bunch of new Facebook social plugins you can add to your website. One of the things that you can do immediately is allow your visitors to “Like” any web page or blog post on your site by adding a few simple lines of code. You can literally treat URL on your website like a Facebook page!
Here’s an example of a button that shows your visitor who else in their social network “Liked” this page, and allows them to “Like” your page with a comment too.
It’s dynamic – go ahead – Click It!
Adding Facebook Social Plugins to Your Blog (or Website)
Adding one of these to your website is super easy. Just go to the Like Button plugin page at Facebook, and they have a tool that helps you get the code.
Enter in the URL of your page and push the Get Code button and you’ll get the code you can embed on your website. You need to use the iFrame version of the code unless you’ve added the Facebook JavaScript SDK to your site.

What if I want to Add it to ALL my Blog Posts?
That’s cool for an individual page or post on your site, but what if you want to include this on all your blog posts?
Well, if you are using the Thesis WordPress Theme you can use “hooks” and a little WordPress code to easily add this to all your blog posts automatically.
Here’s how to do it.
Thesis conveniently provides a hook called thesis_hook_after_post that allows you to add anything you want after every post on your site. Here’s the code you need to add to that hook to get this new Facebook Like Button to show up at the bottom of every post:
/* Facebook Plugin After Post Hook */
function add_social_media () {
if (is_single()) {
?>
<?php
echo '<iframe src="http://www.facebook.com/widgets/like.php?href=';
echo the_permalink();
echo ' "scrolling="no" frameborder="0" style="border:none; width:450px;height:30px"></iframe>'
?>
<?php
}
}
add_action('thesis_hook_after_post', 'add_social_media');
The WordPress function the_permalink(); gives you the URL of your blog post so that the likes are unique to the particular post instead of your whole blog.
You can add this hook to your custom_functions.php file like this, or using the Rick Beckman’s excellent OpenHook plugin.
If you use OpenHook to do this, you’ll want to leave out the function wrapper and add_action. So the code you paste in the after_post_hook box will look like this:
<?php
echo '<iframe src="http://www.facebook.com/widgets/like.php?href=';
echo the_permalink();
echo ' "scrolling="no" frameborder="0" style="border:none; width:450px;height:30px"></iframe>'
?>
Give it a try and let me know what you think in the comments below!
You can Get Thesis here. I recommend BlueHost for WordPress hosting.
If so, please join over 10,000 people who receive exclusive weekly online business and blogging tips, and get a FREE COPY of my eBook, 10 Steps to Free Website Traffic! Just enter your name and email below:
If you're building a business website these days, you're in luck.
WordPress has revolutionized the ease and power of what a website can do and be. Now you can quickly create a website that is optimized for top search results, and update it yourself whenever you want.
As you'll see in a moment, the SmallBiz Theme is much more than a mere WordPress theme. It's a complete solution for your business web presence including a Website, Blog, Facebook Page and Mobile Website.
Let's take a look at each of these, and how they help you generate new business from the web…
Click to continue...See my disclosure about advertising and affiliate links







{ 33 comments… read them below or add one }
I added the code into the “thesis_hook_after_post” just like you said but it’s not working and killing the layout of my homepage.
Hi Aaron,
How did you add it – did you use OpenHook or edit your custom functions file? If you used OpenHook, you’ll need to check the “execute PHP” checkbox for it to work. If you did it in custom_functions.php, did you add it at the end?
The code that I’ve included here is working on this blog, so I know it is good. We need to figure out if something got left out in the PHP code in your custom_functions.php file…
The new update you just posted fixed the problem.
Thanks a bunch Don, as always you’re always cutting edge and I love that.
Best Aaron.
This literally took me 1 minute to do!!! Thank you so much, your tips are always so valuable. Aaron, excellent question (and Don thanks for the quick answer), I would not have known to check the “execute PHP” button.
@Aaron, @Eileen, great – I’m glad you got it working!
It’s pretty cool to play with. Next step, I’m working on getting the more advanced one that shows pictures and allows you to leave a comment. Stay tuned!
Your post has made my day! First, I was unaware of the OpenHook plugin so, it’s refreshing to know how much time will be saved by using it. Installing the like button for all posts via OpenHook was ridiculously simple and took about 30 seconds to have it working on my site.
It’s very exciting, what’s going on with the semantic web. Being able to implement it with facebook so quickly and easily is awesome! Don, thanks for your great posts. I’m certainly not going to waste any time trying to install any other new facebook functions, so I’m looking forward to your next post on adding advanced functions and more.
@Jimmy – Awesome!
I’ve got a new tip in the works now…
Hi Don, thanks for the tip. I was playing around with the width and height and changed them to 900 and 60 respectively. Also put the like button at the top of the post. Pretty cool result, I think!
Hey Dean – I checked out your site and it looks great!
Thanks Don – Keep the great stuff coming!
Hey Don, how do we add in the comments field to this also? I just saw it on this site … http://www.people.com/people/article/0,,20363839,00.html
Thanks Kiwi.
The like button seems to not be working in IE 7. Can anyone else confirm? I get an “error on page” message. “Env is undefined”.
This would be great if it would work properly. Seems buggy and clunky so far (typical facebook).
In addition, one issue I see with this button is a new way for people to spam. After you click the like button it just posts the link to your profile without warning. The user wouldn’t know if they are recommending something undesirable until they view their facebook account. (may be too late by then). I wonder why they wouldn’t give the user a preview of what will display in their profile first. …..Not good thinking facebook
Just my 2 cents
Hi Kevin,
Can you give me a link to your site? I tested another site in IE and the Share Link worked. But I did find that it conflicts with the Facebook Fan Box widget though. It is definitely rough at this point.
Also, I agree with your point about the preview before posting your FB profile. They should absolutely do that.
Hi Don,
Thanks for the reply.
I was actually getting it from clicking on the “like” button on this post and others on your blog. I’m not getting it anymore though. May have been a conflict with another page I had open? Seems to be working fine now.
Definately a few bugs to work out but lots of opportunity I think.
Kevin thanks for the reminder to check Explorer, I always forget. My site looks okay and seems to be working fine, but I am using 8.0 (http://eileenlonergan.com)
I would like to exempt some of my pages from this button.
Any suggestions as to how I might be able to do this
Thanks
It’s work very well.. great! Thanks Don Campbell
Syafiq Zainal
I think instead of the trackback URL could be better to use the_permalink() function to get the real URL of the post. That way can boost the SEO for this post, as Google and Facebook will realize loves that post (like the ones you write Don).
What do u think?
All the best.
@Sapitt – you’re very welcome!
@Esteve – I agree with you and updated the post. the_permalink() is better.
@Pete – well, to add it to only select pages, you can just cut and paste the iframe code you get from Facebook.
If you want it to be added automatically but not show up for certain pages, which pages do you want it to NOT show up for?
All pages in a certain category? Pages and not posts? You could do that with conditional logic. But I would have to know more about what your “exclude” criteria are.
This worked like a dream using the openhooks plugin. Much appreciated.
Thank you! I’m a new Thesis theme owner setting up my blog and your tutorial worked well… easy enough for a beginner like me! Thanks for sharing it! – Michelle
You’re the man!
Thank you for your post. It was so helpful for me!
Wow that is the coolest integration of facebook like count box + twitter count box + email icon I have seen! Would you mind sharing how you did the email icon? Thanks!
Hi James,
Thank you. I just used an e-mail icon and used the mailto: href tag to create an email when someone clicks on it. Then some CSS to line things up properly.
I got the idea from: http://litemind.com/
Hello Don,
Like always your tips work out great for me! I was wondering, how do I get my blog entries that show up on my fan page to link to my website? I was told to link my blog through the notes app on FB but if someone were to visit my fan page and click on the blog entry in the status updates it takes them back to my notes page on FB instead of the blog. Is there a plugin that could link all this together so that I can have traffic going back and forth? Thanks Don
Hi Mark,
You ran into the exact reason I don’t use the Facebook Notes app for this. There are several Facebook Apps developed by third parties that you can use. Dlvr.it is a good one. Here’s an article that will get you started: http://www.eileenlonergan.com/how-to-change-the-default-image-in-dlvr-it
Thanks so much for your help Don!
@Don, thank you for the shout out. Mark if I can answer any questions about dlvr.it please let me know!
Thank you Eileen! I’ll take a look at it this weekend and let you know how it goes.
Thank you! I’m a new Thesis theme owner setting up my blog and your tutorial worked well… easy enough for a beginner like me!
Thanks for this! Been having problems with Facebook/social plugins and Thesis. How do I add Like/Send/Tweet/Google+1 and have them aligned nicely like yours? Are you using a separate plugin for the Tweet/+1?
Whenever I use plugins, the alignment seems to be off(when Google +1 is used). I’m thinking it might be better to just use coding and OpenHook.
Any advice?
Thanks
Thanks for your help! How can I post the FB like bottom to each post on the front page and the post page at the same time?
{ 1 trackback }