Facebook Open Graph tags for WordPress

Maybe you heard about the Opengraph Tags used by Facebook ? Basically “including Open Graph tags on your Web page, makes your page equivalent to a Facebook Page”:


And yes, you’ll get a nice like Thumbnail of your web page using this stuff (knowing that the share function is now deprecated: http://developers.facebook.com/docs/share/ and has been replaced with like).

This is a quick code for WordPress (minimal tags), just adapt, then copy & paste to your wordpress theme header:

<meta property="og:image" content="<?php echo "http://".$_SERVER['SERVER_NAME'];?>/wp-content/path-to-your-logo"/>
<meta property="og:title" content="<?php if (is_home () ) { bloginfo('name'); }
elseif ( is_category() ) { single_cat_title(); echo ' - ' ; bloginfo('name'); }
elseif (is_single() ) { single_post_title(); }
elseif (is_page() ) { bloginfo('name'); echo ': '; single_post_title(); }
else { wp_title('',true); } ?>"/><meta property="og:type" content="<?php if (is_home () ) {echo 'blog';} else {echo'article';} ?>"/>
<meta property="og:url" content="http://<?php echo $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"] ?>"/>
<meta property="og:locale" content="<?php echo get_locale(); ?>"/>


Right there you can put your Facebook account or page ID in content, you can leave it empty:

<meta property="fb:admins" content=""/>

This one is an old syntax, still useful for a thumbnail somehow:

<link rel="image_src" href="<?php echo "http://". $_SERVER['SERVER_NAME'];?>/wp-content/path-to-yout-logo"/>


Finally, just check your page using the Facebook validator tool:



That’s all 


1 Response to “Facebook Open Graph tags for WordPress”

  1. October 18, 2012 at 10:28

    Fabulous, what a weblog it is! This webpage provides helpful data to us, keep it up.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: