20
Dec
11

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”:

http://developers.facebook.com/docs/opengraph/

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:

http://developers.facebook.com/tools/debug

 

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 to Rozliczanie PIT Cancel reply