Skip to content

Instantly share code, notes, and snippets.

Created November 24, 2015 23:39
What would you like to do?
Easily include the Facebook SDK script, useful when adding Facebook Social Plugins to your site:
* Plugin Name: Genesis - Facebook SDK
* Plugin URI:
* Description: Adds the Facebook SDK script just after the opening <body> tag on Genesis Framework sites.
* Version: 1.0.0
* Author: Erica Franz
* Author URI:
* License: GPL2
defined( 'ABSPATH' ) or die( 'No jellyfish!' );
add_action( 'genesis_before', 'fb_sdk_output' );
* Facebook recommends adding the SDK script just after the opening <body> tag.
* Let's hook into 'genesis_before' to do this.
function fb_sdk_output() {
echo '<div id="fb-root"></div>
<script>(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); = id;
js.src = "//";
fjs.parentNode.insertBefore(js, fjs);
}(document, "script", "facebook-jssdk"));</script>';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment