Adding Google+ Meta Tags in WordPress

If you’ve decided to include a Google+ button on your WordPress site, it’s also suggested that you add a few new meta tags to your header so that you can customize exactly what appears when people share your page on Google+. You can read more about the requirements at http://www.google.com/webmasters/+1/button/. Here is a quick snippet that you can add to your theme’s functions.php file that will add your post’s title, excerpt and featured image to the appropriate meta tags:
/**
 * Add Google+ meta tags to header
 *
 * @uses	get_the_ID()  Get post ID
 * @uses	setup_postdata()  setup postdata to get the excerpt
 * @uses	wp_get_attachment_image_src()  Get thumbnail src
 * @uses	get_post_thumbnail_id  Get thumbnail ID
 * @uses	the_title()  Display the post title
 *
 * @author c.bavota
 */
add_action( 'wp_head', 'add_google_plus_meta' );

function add_google_plus_meta() {
	
	if( is_single() ) {
		
		global $post;
		
		$post_id = get_the_ID();
		setup_postdata( $post );
		
		$thumbnail = wp_get_attachment_image_src( get_post_thumbnail_id( $post_id ), 'thumbnail' );
		$thumbnail = empty( $thumbnail ) ? '' : '';
	?>
	






	

Now you can use the code supplied on http://www.google.com/webmasters/+1/button/ to included the Google+ button wherever you want on your site. I stuck it into the single.php file next to my other social media buttons. You can see them all below.
				

Small Biz Website Tips Newsletter

Stay up to date with the latest marketing, sales, and service tips and news.