I'm trying to get the Facebook Open graph tags for posts working, but they don't apear in the the post header no matter what I do. I'm using this code in
functions.php file and
Lifestyle 3.0 theme:
PHP Code:
<?php
// Paste into Functions.php, anywhere between the PHP tags
add_action('wp_head', 'add_fb_open_graph_tags');
function add_fb_open_graph_tags() {
if (is_single()) {
global $post;
if(get_the_post_thumbnail($post->ID, 'thumbnail')) {
$thumbnail_id = get_post_thumbnail_id($post->ID);
$thumbnail_object = get_post($thumbnail_id);
$image = $thumbnail_object->guid;
} else {
$image = 'http://www.bodieko.si/foto/2011/04/eko.jpg'; // Change this to the URL of the logo you want beside your links shown on Facebook
}
$description = get_bloginfo('description');
?>
<meta property="og:title" content="<?php the_title(); ?>" />
<meta property="og:type" content="article" />
<meta property="og:image" content="<?php echo $image; ?>" />
<meta property="og:url" content="<?php the_permalink(); ?>" />
<meta property="og:description" content="<?php echo $description ?>" />
<meta property="og:site_name" content="<?php echo get_bloginfo('name'); ?>" />
<meta property="fb:admins" content="000000000000" />
<?php }
}
// Update your fb:admins to your user or page ID
?>