Skip to content

Instantly share code, notes, and snippets.

//Add Open Graph Meta Info from the actual article data, or customize as necessary
function insert_fb_in_head() {
global $post;
if ( !is_singular()) //if it is not a post or a page
return;
//You'll need to find you Facebook profile Id and add it as the admin
echo '<meta property="fb:admins" content="XXXXXXXXX-fb-admin-id"/>';
echo '<meta property="og:title" content="' . get_the_title() . '"/>';
echo '<meta property="og:type" content="article"/>';
echo '<meta property="og:url" content="' . get_permalink() . '"/>';
function add_opengraph_doctype($output) {
return $output . '
xmlns="https://www.w3.org/1999/xhtml"
xmlns:og="https://ogp.me/ns#"
xmlns:fb="http://www.facebook.com/2008/fbml"';
}
add_filter('language_attributes', 'add_opengraph_doctype');