Thord Daniel Hedengren - Smashing WordPress_ Beyond the Blog-Wiley (2014)

(avery) #1

240 PART IV • Additional Features and Functionality


INTEGRATING FACEBOOK INTO YOUR SITE


I’m starting with Facebook because this is not only the largest social network as I’m writing
this but also by far the easiest to integrate into a site, at least on its most basic level. Facebook
has excellent tools to help you integrate its features into your site; just check out the Social
Plugins page at http://developers.facebook.com/docs/reference/plugins
for a lot of alternatives (see Figure 10-1).

Figure 10-1: Facebook has great tools for adding related features to your site.

Most often, you want to promote two things on your site when it comes to Facebook: having
people “like” your content and your Facebook fan page.

THE LIKE BUTTON
The Facebook Like button is incredibly easy to integrate. Just go to this page and build your
own button: http://developers.facebook.com/docs/reference/plugins/
like.

Don’t worry about the URL to Like field as I’ll show you how to swap it for the_
permalink() template tag anyway. Just put something in there; for this example,
I added http://tdh.me to this field.

Clicking Get Code will get you three different code snippets; one is for HTML5 (which is the
one most of us want to use), one is for XFBML (extended Facebook markup language) users,
and the third is a simple iframe that might not always be available for your Facebook needs. In
most cases, you’ll be using the HTML5 code snippet, so go ahead and copy and paste that one.
As you can see, it consists of two parts, one for getting Facebook’s JavaScript API onto your site:
Free download pdf