Blogger Widgets

Social WEB

Add Google+ Automatically to Each Post


Google Plus (+) is a new service from Google, which can bring traffic to your blog just like other social networking sites as such as Twitter or Facebook. Now, I’m going to show you how to automatically add a Google plus (+) button to your posts.
Well to add the Google Plus (+) button is easy just add the below piece of code infunctions.php of your theme :
add_filter('the_content', 'wpr_google_plusone');
function wpr_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','wpr_google_plusone_script');
function wpr_google_plusone_script() {
 wp_enqueue_script('google-plusone', 'https://apis.google.com/js/plusone.js', array(), null);
}