Skip to content

Instantly share code, notes, and snippets.

@billerickson
Created September 20, 2011 13:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save billerickson/1229106 to your computer and use it in GitHub Desktop.
Save billerickson/1229106 to your computer and use it in GitHub Desktop.
Facebook Like on Genesis
//** This goes in the setup function **//
// Remove the default doctype and build our own
remove_action( 'genesis_doctype', 'genesis_do_doctype' );
add_action( 'genesis_doctype', 'be_do_doctype' );
// Add facebook's meta tags
add_action( 'wp_head', 'be_facebook_meta' );
//** This goes at the bottom of functions.php **//
function be_do_doctype() {
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:og="http://opengraphprotocol.org/schema/" xmlns:fb="http://www.facebook.com/2008/fbml" <?php language_attributes( 'xhtml' ); ?>>
<head profile="http://gmpg.org/xfn/11">
<meta http-equiv="Content-Type" content="<?php bloginfo( 'html_type' ); ?>; charset=<?php bloginfo( 'charset' ); ?>" />
<?php
}
function be_facebook_meta() {
?>
<meta property="fb:admins" content="YOUR-ADMIN-ID"/>
<meta property="fb:app_id" content="YOUR-APP-ID" />
<meta property="og:type" content="article" />
<?php if(is_home()) {
?><meta property="og:title" content="My Blog Name" /><?php
} else {
?><meta property="og:title" content="<?php the_title_attribute( $args ); ?>" /><?php
}
?>
<?php if (is_home())
echo '<meta property="og:url" content="YOUR-APP-URL" />';
else echo '<meta property="og:url" content="'.get_permalink().'" />';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment