WordPress

Automatically Add Google+ Button After Post

Google Plus

Google+ is the latest social media trend to hit the internet, it is growing in users all the time and it is fast becoming a very engaging community. You will find that because you can share content with a comment with targeted people you will get more interaction with each article you share. This can drive a lot of traffic to your website but you need to get different people sharing your content.

In this snippet it allows you add a Google+ button to the bottom of each post on your WordPress blog.

Just add the following snippet to your functions.php page.

add_filter('the_content', 'google_plus');
function google_plus($content) {
	$content = $content.'<g:plusone size="tall" href="'.get_permalink().'"></g:plusone>';
	return $content;
}
add_action ('wp_enqueue_scripts','google_plus_script');
function google_plus_script() {
	wp_enqueue_script('google-plus', 'https://apis.google.com/js/plusone.js', array(), null);
}
Back to top ^

Leave a Reply

Your email address will not be published. Required fields are marked *

Join Paulund

  • Access 100s of premium tutorials and downloadable content
  • Members content consists of premium WordPress plugins, CSS packages, jQuery packages, tutorial demo files and templates for 100s of web development tutorials
  • In-depth development tutorials
  • Priority tutorial requests
  • No ads

Join Paulund