Adding the Facebook Like button to your website is pretty easy when you're running a standard template - you drop some code in the header.php and single.php files. But if you're running Genesis or Thesis, you'll have to use functions to add it.
For both of these themes there are plugins that let you add PHP code through the WordPress interface ( Thesis OpenHook and Genesis Simple Hooks ). I would highly suggest not using these plugins, because if you type something wrong you might break your website and not be able to log back in to fix it.
For both of these themes I'll be sticking the Facebook Like code right above the post content on the individual posts. If you would like it placed elsewhere, refer to a visual guide ( Thesis Visual Hook Reference or Genesis Visual Hook Reference ).
Facebook Like in Thesis
Paste this code in your custom_functions.php file:
[gist id="1325380"]
The first part checks to see if it's a single post (so not the homepage, category page...) and if it is it sticks the facebook code right before the post content.
The second part sticks some information that Facebook wants in the <head> of the site. If it's a single post (which it should always be since that's only where the like code shows up) then it uses the title of the page. If it's not a single post (if you changed the is_single() in the first code block to something else) it will show the site name followed by the site description. I then specify the image to use as the logo (location: /custom/images/logo.jpg). If you want to use a different image make sure to change this.
Facebook Like in Genesis
In your child theme, place this code in functions.php:
[gist id="1325454"]
The first part checks to see if it's a single post (so not the homepage, category page...) and if it is it sticks the facebook code right before the post content.
The second part sticks some information that Facebook wants in the <head> of the site. If it's a single post (which it should always be since that's only where the like code shows up) then it uses the title of the page. If it's not a single post (if you changed the is_single() in the first code block to something else) it will show the site name followed by the site description. I then specify the image to use as the logo (location: /images/logo.jpg). If you want to use a different image make sure to change this.
No comments yet