WordPress: How to add Google + share button

WordPress: How to add Google + share button

Need to add Google Plus One (Google +) sharing button on your WordPress website or blog? You can generate the code from Google site and add it to “single.php” to make it appear on post pages. Instead of doing this, you can also add Google + button by adding it to the content of posts and pages through “functions.php” file. Copy-paste the code below to “functions.php” file of your WordPress theme and you are done.

add_filter('the_content', 'add_google_plusone');
function add_google_plusone($content) {
	$content = $content.'<div class="plusone"><g:plusone size="tall" href="'.get_permalink().'"></g:plusone></div>';
	return $content;
}
add_action ('wp_enqueue_scripts','add_google_plusone_script');
function add_google_plusone_script() {
	wp_enqueue_script('google-plusone', 'https://apis.google.com/js/plusone.js', array(), null);
}