wordpress snippets last updated   : January 29, 2015
we now have 646 snippets

Automatically add the Google +1 button

wordpress snippet

Adding this snippet to the functions.php of your wordpress theme will automatically add the Google +1 button to your wordpress posts. This is a great little snippet from ottopress.com

snippet :  PHPcopy
add_filter('the_content', 'google_plusone');
function 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','google_plusone_script');
function google_plusone_script() {
	wp_enqueue_script('google-plusone', 'https://apis.google.com/js/plusone.js', array(), null);
source →

Did you like this post? If so please share it with your friends. Thanks!

  • http://wellbeing-support.com Ana Peterson

    Does it works with the new asynchronous code?

    • http://wpsnipp.com Kevin Chard

      Hi Ana,
      Ill post an updated version with the asynchronous code,

      • http://wellbeing-support.com Ana Peterson

        Thanks Kevin. I will put in footer.php for now. I think that your option is great for wordpress, thumblr .. etc users. What do you think?

        • http://wpsnipp.com Kevin Chard

          Hi Ana,
          This code will only work for wordpress.

  • http://gadgetsnewsline.com/ Gadgets NewsLine

    Thanks for the share, will make a try of it.

    • http://wpsnipp.com Kevin Chard

      Glad to hear it!