Beginner's Guide for WordPress - Start your WordPress Blog in minutes.
Choosing the Best
WordPress Hosting
How to Easily
Install WordPress
Recommended
WordPress Plugins
View all Guides

How to Add the Google +1 Button to your WordPress

Last updated on by
Elegant Themes
How to Add the Google +1 Button to your WordPress

Yesterday, Google announced the launch of their much waited +1 button. This is a huge step towards adding the social aspects to the search results. In this article, we will discuss everything you need to know about Google +1 button including the step by step guide to adding it in your WordPress blog or site.

What is the Google +1 Button?

Google’s +1 button is a huge step toward adding social aspect to search results. It is a similar concept as Facebook Like button except it is for search results. In google’s word, it is your friend’s way of saying “this is pretty cool” or “you should check this out”. In another words, it is a public way of stamping something with your approval, so your friends, contacts, and others on the web find the best results when they search. This +1 button is currently available on English searches for Google.com.

Similar to the Facebook Like Button, Google +1 button will also show faces of your contacts (Gmail, Buzz, and Reader).

Why use Google +1 Button?

While Google has stated that this will not affect search ranking, in the interview with Mashable, Google rep Jim Prosser said this is something that the company is “very interested” in incorporating in some form at some point in the future. It is already true that when you are logged in to Google, you see different results than when you are logged out. We believe that this +1 button will certainly have a significant impact on search results in the near future even if the public announcement is not made. So it is best that you start using it right away and take full advantage of it.

We could only imagine this is something that will be added into the Google Banner ads and potentially in other social networks in the future.

How to Add Google +1 in WordPress

Google has created an official page for publishers which contains numerous sizes however there are some customizations that you may need to make if you are using WordPress. So follow the steps below:

Open your theme’s footer.php file and paste the following code above the closing of your body tag:

<script type="text/javascript" src="http://apis.google.com/js/plusone.js"></script>

If you are using a theme framework in which case you will not have the footer.php file, then paste the following code in your functions.php file or custom functions area:

function add_googleplusone() {
echo '<script type="text/javascript" src="http://apis.google.com/js/plusone.js"></script>';
}
add_action('wp_footer', 'add_googleplusone');

Once you have pasted the JavaScript, now open your theme file where you want to add the Google +1 Button. Most likely it will be your single.php file. Before you go ahead with this, there are numerous size options. Below is a reference guide:

Google Plus One Size Display

The code to paste in your template for each size is below. Just copy the one that you like and paste it inside your post’s loop.

//Code to paste for the Tall Button
<g:plusone size="tall" href="<?php the_permalink(); ?>"></g:plusone>

//Code to paste for the Standard button
<g:plusone href="<?php the_permalink(); ?>"></g:plusone>

//Code to paste for the Medium Button
<g:plusone size="medium" href="<?php the_permalink(); ?>"></g:plusone>

//Code to paste for the Small Button
<g:plusone size="small" href="<?php the_permalink(); ?>"></g:plusone>

If you want to show the button without count, then you can add the parameter count=”false” in the code above. An example of the code should look like this (Note this does not work with the Tall size because it must have the count):

<g:plusone size="small" count="false" href="<?php the_permalink(); ?>"></g:plusone>

Yoast shared a very interesting tip yesterday by showing how you can track Google +1 interaction in Google Analytics. If you want to track the interaction of your Google +1 button, then change the Google +1 code to look like this:

<g:plusone size="tall" callback="plusone_vote"></g:plusone>

And then add the following code in your site’s footer below the script that we added in step 1. Example code should look like this:

<script type="text/javascript" src="http://apis.google.com/js/plusone.js"></script>
<script type="text/javascript"> 
			function plusone_vote( obj ) {
				_gaq.push(['_trackEvent','plusone',obj.state]);
			}
</script>

We have already added the button on our site. Will you be adding / using it?


Editorial Staff at WPBeginner is a team of WordPress lovers led by Syed Balkhi. Page maintained by Syed Balkhi.

WPBeginner's Video Icon
Our HD-Quality tutorial videos for WordPress Beginners will teach you how to use WordPress to create and manage your own website in about an hour. Get started now »

Comments

  1. arionarian says:

     @wpbeginner  why i still get +1 button errors when i tried to click this button ?

  2. farid999 says:

    Dear, how to add Google + button in every post automatically of my wp site?

  3. gokhanzburnu says:

    I wonder if it also has a dislike feature which is frequently abused for example on YouTube. I understand that any rating counts for more than no rating but rating with the intention to do harm rather than good to someone is pathetic.

    We will try to get as much as +1 we can because we know the benefit of it with seo prespective (and soon we will see many people started to sell +1 as well) but a normal user do not know about it and where facebook like button is one step ahead from it. @arabsciences

  4. wpbeginner says:

    @JonathanDanielKeck you can wrap it around a div and add custom inline-styling… style=”padding: 0 0 0 25px;” play around with the padding until you get it right.

  5. JonathanDanielKeck says:

    @wpbeginner I see what you are saying. The Google+ is off to the left. How do I shift it to the center?

  6. wpbeginner says:

    @adrianaephotography @wpbeginner @merrittsgret We just added a div with extra padding.

  7. adrianaephotography says:

    @wpbeginner @merrittsgret I meant to say “mine shows” not “my shows”

  8. adrianaephotography says:

    @wpbeginner @merrittsgret How did you leave that little space in between the separating line and the button? My shows centered and everything, but with no space from the separating line. I tried adding a <br> but the space it too much. Thanks,

  9. mrahmadawais says:

    i also need this

  10. wpbeginner says:

    @merrittsgret You would need to align the div that google+ button is in. Look through our site’s CSS to see how we have the G+ button aligned in the floating bar…

  11. merrittsgret says:

    Any way yet to format the placement of the Google Plus button using CSS? I can’t get it to line up with the rest of my share buttons (example http://ylcf.org/2011/07/faith-blind/).

  12. AlexShalman says:

    @AlexShalmanI used the <center> tag and it got it pretty close (although slightly different from the rest of the icons).

  13. AlexShalman says:

    I added the smart share plugin, and followed your instructions on adding google plus to it on AlexShalman.com – if you look at a single post page, you will see that the GooglePlus icon is off to the left side of the box, instead of centered. Would you be so kind as to tell me how to center it?

  14. wpbeginner says:

    @Kamil_ace Copy the code and paste it in the custom code area. Might have to tweak the styling…

  15. Kamil_ace says:

    how do i add the button in smart sharing plugin?

  16. TimRSMartin says:

    @wpbeginner @georgetasioulis I was just about to download your floating social tool bar, has the google +1 been added to it?

    Thanks

  17. wpbeginner says:

    @IPodsIPhones To clarify on that, Google +1 button is only showing in the U.S search engines. It is however shown to all users we believe.

  18. IPodsIPhones says:

    No doubt awesome plugin and i have added it on my site but I am not confirm that if I am not in U.S, then Google +1 button would not work. Please tell me about this.

  19. itsdaniel0 says:

    @wpbeginner @michel.fortin I placed CloudFlare in development mode, it worked, turned development mode off, and it still seems to be working!

  20. wpbeginner says:

    @michel.fortin @itsdaniel0 great find :)

  21. michel.fortin says:

    @wpbeginner @itsdaniel0 Found the culprit. It was the Bad Behavior plugin. Once deactivated, the +1 worked.

  22. georgetasioulis says:

    @wpbeginner thnx I will check it out ;)

  23. wpbeginner says:

    @georgetasioulis We are using a variation of Smart Sharing Plugin.

  24. georgetasioulis says:

    Which plugin do you use for your floating sharing bar on the left of the posts?

  25. coolcash4live says:

    This is awesome post. Thanks for this information

  26. abdelhafidcom says:

    definitely …. i already add it to my wordpress blog

  27. coolgizmotoys says:

    @arabsciences I use the floater on my site: http://www.coolgizmotoys.com. Is there an easy way to add +1 to the floater? Thanks!

  28. wpbeginner says:

    @itsdaniel0 @michel.fortin Just did a quick research. It seems that a lot of users are having this issue. Don’t know the cause of it yet. Will stay on top of it.

  29. wpbeginner says:

    @itsdaniel0 @michel.fortin Don’t know this issue of red exclamation mark. But as many resources suggests: This is only open for U.S audience.

  30. itsdaniel0 says:

    @michel.fortin @wpbeginner I’m having the same issue here, red exclamation mark on my site, works fine on yours

  31. michel.fortin says:

    @wpbeginner @michel.fortin You mean if my site is not in the US? Because it does add others I click (like this page, for example) to my profile (and I’m Canadian).

  32. wpbeginner says:

    @michel.fortin If you are not in U.S, then it wouldn’t work. Other than that, don’t know why it wouldn’t work for you.

  33. michel.fortin says:

    Seems like I keep getting the red exclamation mark button from Google. But their explanation doesn’t make sense. They say my internet connection is slow… but it works on other sites. Why not mine? I’m at a loss…

  34. capecalendar says:

    @wpbeginner

    Fantastic > Working > Just need to move things around a bit. on whatsupcapetown.com > Thanks a mill >> :-)

  35. wpbeginner says:

    @capecalendar Try the code now.

  36. capecalendar says:

    I am using the Genesis framework and using your code in the functions.php file gives me an error when loading the site. The error is:

    Parse error: syntax error, unexpected ‘{‘, expecting ‘ >>>>etc.

    Can someone please help me fix this.

  37. wpbeginner says:

    @dicarlod Open the Widgets area and drop the code there :) But remember to put your site’s url there.

  38. dicarlod says:

    hey :)

    and how can we add it to the side bar ?

  39. strawberrysingh says:

    I added it to my blog a few days ago but I wish I had read your tutorial first, it took me forever to figure it out. This is so much easier! :D Thanks for sharing. <3

  40. webgrafia says:

    Try this:

    http://wordpress.org/extend/plugins/google-plus1-button/

    released yesterday, suggestion for better development is appreciated

  41. AzharKamar says:

    @NemeshSingh nah, this is already very easy. ;)

  42. AzharKamar says:

    Awesome tutorial! Now I have the button in my site. ;D

  43. NemeshSingh says:

    Use this wordpress plugin instead http://wordpress.org/extend/plugins/google-plus-one-google1/ :) I hope this helps :)

  44. wpbeginner says:

    @SallyE@ericksonweb Ah yea… the floater is a bit crazy right now. We have added the +1 button right next to the big like button as well above post content. Thanks for the suggestion. We will fix the floater as well.

  45. SallyE says:

    @wpbeginner@ericksonweb You missed the point on the plug in I was talking about. I mean the one this website is using on my left, which I can only see 1/4 ” I understood the rest of your post fine and it’s very clear.

  46. wpbeginner says:

    @SallyE@ericksonweb I suppose the above method is not clear enough for non coders. Unfortunately, at the moment that is the only way. We will keep an eye out for plugins.

  47. SallyE says:

    Hi Guys,

    Thanks for all the great info on Google’s +1 Button! I hoped one of you in the know would take the time to let us not-so-talented peops in on the steps and the use.

    I can almost see where you added the button here on the left. I’m in Safari on the Mac and can see about a 1/4″ of its right side. Hardly recognizable and a very small click area. Think this plugin/code might need some work. @EricksonWeb

  48. arabsciences says:

    I have added it.

  49. wpbeginner says:

     @Eat Stop Eat You see where it says the_permalink in the href tag. Replace that php code with your site’s URL.

Add a Comment

We're glad you have chosen to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.