Family Encyclopedia >> Electronics

How to Add the Google+ 'Add to Circles' Badge to Your WordPress Site

Recently, one of our readers inquired about adding the Google+ "Add to Circles" badge to their WordPress site. We've previously covered integrating the Google +1 button into WordPress posts. In this guide, we'll walk you through adding the "Add to Circles" badge step by step.

Preview of the Google+ badge:

How to Add the Google+  Add to Circles  Badge to Your WordPress Site

Important note: This works only for Google+ pages, not personal profiles. Example of the Google+ page. Google+ profile example.

First, add this JavaScript code to the <head> section of your site by editing your theme's header.php file:

(function() {
  var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
  po.src = 'https://apis.google.com/js/plusone.js';
  var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
})();

Next, locate your Google+ Page ID—it's the 21-digit string at the end of your page URL. For example, in https://plus.google.com/101634180904808003404/, the bold numbers are your Page ID.

After adding the script, place this code wherever you want the badge to appear, such as in your sidebar.php file or a text widget:

<div class="g-addToCircle" data-href="//plus.google.com/YOUR_PAGE_ID"></div>

Replace YOUR_PAGE_ID with your actual 21-digit Page ID.

For the small badge, use this version:

<div class="g-addToCircle" data-size="small" data-href="//plus.google.com/YOUR_PAGE_ID"></div>

We hope this guide helps you integrate the badge seamlessly. If so, please consider adding WPBeginner to your circles.