It’s recently been announced that the number of +1’s your site receives might affect your Google page rank so it’s worth having a Google +1 button on your site.
The obvious way to add a single Google +1 button is to just use a WordPress Google +1 plugin but what if you want to keep plugin numbers down for performance reasons or want to add multiple instances of Google +1 to your site, all promoting different url’s, ie – one at the top of your home page for your main site url and one on individual blog posts? Well this is what I needed to do and found it wasn’t that easy! Here’s how I managed it:
Go to www.google.com/webmasters/+1/button and grab your button code, making sure to enter a target url for your main site, then paste it into your site template, taking care to paste the right bits in the right places. The following goes in your header.php file in the <head> section:
And the following goes wherever you want the button to show, typically inside the header.php file somewhere after the opening <body> tag:
<!-- Place this tag where you want the +1 button to render --> <g:plusone annotation="inline" href="http://www.reverbstudios.ie"></g:plusone>
Now, if you wanted to also have a button on each blog post, to specifically target that blog post url, you need to paste the above code into your single.php template file, somewhere inside the loop but this time change the url to “<?php the_permalink(); ?>”, ie:
<!-- Place this tag where you want the +1 button to render --> <g:plusone annotation="inline" href="<?php the_permalink(); ?>"></g:plusone>
What this does is automatically grab the post url of the post your’re currently reading and allows it to be +1’d!
See the top left of this site and the share section just below this blog post’s title to see both buttons in action.
2 thoughts on “Add Multiple Google +1 Buttons to WordPress”
In my blog I described how to add Google +1 Button to every WordPress blog post in respect to iNove theme. I added the +1 button manually editing php files. Probably, it could be useful for someone. The article is here – WordPress: How to add Google +1 Button to WordPress blog post.
Easy to understand..thanks I +1 you