Add Open Graph Tags to WordPress Theme

In your theme header.php

Change “head” tag to:

<head <?php if (is_single()): ?>prefix="og: http://ogp.me/ns# fb: http://ogp.me/ns/fb# article: http://ogp.me/ns/article#"<?php endif; ?>>

And then add meta-tags between the end “head” tag:

<?php 
	if (is_single()):
		while ( have_posts() ) : the_post(); 
			$og_image_attributes = wp_get_attachment_image_src(get_post_thumbnail_id(), 'homepage-image'); // returns an array
			$og_image = $og_image_attributes[0];
?>
			<meta property="og:title" content="<?php echo $post->post_title; ?>"/>
			<meta property="og:type" content="article"/>
			<meta property="og:url" content="<?php echo get_permalink( $post->ID );?>"/>
			<meta property="og:image" content="<?php echo $og_image; ?>"/>
<?php 
		endwhile;
	endif; 
?>