How To Set Up WordPress Social Metadata
August 21st, 2012 by
<link>
tag rather than the more complicated three-link monte from earlier. In this tutorial, we use built-in WordPress functions to edit the theme of your site to create a semi-automated, scalable way to correctly generate this metadata.


Which Would You Rather Your Sharers See?
Here’s the video, which will show you the code to set this up and a cute ferret. Enjoy!
Can’t Read the Code?
<!-- Facebook Open Graph! -->
<meta property="og:site_name" content="<?php bloginfo('name');?>" />
<meta property="og:type" content="<?php if(is_single()) {echo 'article';} else {echo 'website';} ?>" />
<meta property="og:locale" content="en_US" />
<meta property="og:title" content="<?php $viral_title=get_post_meta($post->ID,'viral_title',true);
if(!empty($viral_title)){echo $viral_title;}
else{wp_title();} ?>" />
<meta property="og:description" content="<?php $viral_desc=get_post_meta($post->ID,'viral_desc',true);
if(!empty($viral_desc)){echo $viral_desc;}
else{while (have_posts()):the_post();
echo substr(strip_tags(get_the_content(),0,197));echo '...';endwhile;} ?>" />
<meta property="og:image" content="<?php $og_image=get_post_meta($post->ID,'og_image',true);
if(!empty($og_image)){echo $og_image;}
else{bloginfo('template_directory');echo '/og.jpg';} ?>" />
<!-- Twitter Cards (in beta!) -->
<meta name="twitter:card" content="summary" />
<meta name="twitter:site" content="@terrafalsa" />
<meta name="twitter:creator" content="@<?php the_author_meta(aim,$posts[0]->post_author); ?>" />
<!-- Google+ Authorship (header) -->
<link rel="author" href="<?php the_author_meta(url,$posts[0]->post_author); ?>" />