Google Plus One Button and WordPress

Google Like Button

I received a ton of emails recently asking how to use the Google Plus One Button on a WordPress site.

This is extremely easy to do. You can set up everything from inside of WordPress with a few simple copies and pastes.

So, open up your WordPress dashboard on your favorite browser and we’ll be done in a few minutes.

Paste Google Plus One Code in Header.php

First click on Appearance in your WordPress left sidebar and click Editor.

Under Templates in your right sidebar click on the file named header.php. Copy and paste the following line between the <head> tags that you find here:

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

Note: Make sure you don’t paste this between opening and closing php tags.

  • <?php : Opening php tag
  • ?> : Closing php tag
After you copied and pasted the code click on the update button.
Create a WordPress Shortcode for Google Plus One Button
Now we’ll create a shortcode that will allow you to easily place a Google Like Button where ever you’d like.
Click on the file named functions.php in the WordPress Appearance editor. At the end of that file paste in the following code:

<?php

// This code places a Google +1 Button in a post
function showgoogleplusone() {
return ‘<g:plusone></g:plusone>’;
}

add_shortcode(‘googleplusone’, ‘showgoogleplusone’);

?>

Again, watch out for the opening and closing php tags. Don’t paste this between them! Click the update button and now when you type [ googleplusone ] Β in your WordPress posts a Google Plus One button will show up instead like this

Note: make sure you don’t have spaces before and after the words googleplusone in the shortcode above.

Want to Learn More about WordPress

If you want to learn more about WordPress I have the only WordPress Theme and Plugin video Tutorials on the internet here WordPress Theme Development.

Leave any questions or comments below. If you like my site please click that Google +1 Button πŸ™‚ I appreciate it

Think Tank

 

12 Responses to “Google Plus One Button and WordPress”

  1. nice posting +1 from me also i will also use +1 in my posting cheer

  2. Simon says:

    +1ing this post. Awesome videos btw

  3. sergio says:

    hi i would like to implement this too but when i update the functions.php as you said i have a blank website.

    i think because there is a bug in functions.php

    any ideas?

  4. Christoph says:

    Hi there,
    thanks a lot for this helpful site. Finally I got it working!
    But what almost drove me crazy are the typographic quotes you are using in the code. Copy & paste doesn’t work and it’s hard to find out why …

    Plus you’ll need a rel=”canonical” for the button to work properly.

    Cheers,
    Christoph

  5. Thanks for the info. Wondering if there’s a way to create a custom plus one or like button that counts clicks, but isn’t tied to any of the social media sites.

    • admin says:

      Definitely! The easiest way to do that is with JQuery and AJAX techniques. Here is a video AJAX Video Tutorial.

      I’d probably just store the number of clicks in a text file. Pretty simple to set up. Kind of like a hit counter that is tied to clicks on your button

Leave a Reply

Your email address will not be published.

Google+