google-plus-follow-button-wordpress-shortcode

Add a Google Plus Follow Button in WordPress with Shortcode

The Google Plus follow button is an underutilised tool that will display a YouTube Subscribe or Twitter Follow style button from which your visitors can add you to their circles. Unlike the Google Badge the follow button doesn’t display anything other than the follow button (although it’s still far more function than the minimalistic Google+ Icon).

While Google provides a tool that will generate a Follow Button , it always makes more sense to use shortcode for something that might be used more than once.

The Result

Follow buttons can be aligned to the center, or floated left or right (meaning that text will wrap around them). Example of the small, medium, and large follow button with the annotation (count) bubble aligned horizontally are rendered below. They are linked to my personal Google+ profile .

Shortcode: [googleplusfollow size="small"]. The result:

Shortcode: [googleplusfollow size="medium"]. The result:

Shortcode: [googleplusfollow size="large"]. The result:

The same buttons can be rendered with the annotation above the button. The shortcode of annotation="v" should be used.

Shortcode: [googleplusfollow size="small" annotation="v"]. The result:

Shortcode: [googleplusfollow size="medium" annotation="v"]. The result:

Shortcode: [googleplusfollow size="large" annotation="v"]. The result:

Alternatively, no annotation can be displayed at all. The following large button is rendered with [googleplusfollow size="large" annotation="n"].

You may optionally float the follow button to the right or left of your post container with the attribute of align="left|right". The advantage of using this alignment might arise if you are required to wrap text around the button. In the button used in this example we’re referencing the Internoetics Google+ page . When using a page (rather than a personal profile), you must use type="publisher".

The Code

You are required to include Google’s plusone.js JavaScript somewhere on your page. If you’re already using one of our other Google+ shortcodes you won’t have to add the following function again. If not, or if you don’t already include the JavaScript in other ways, you should include the following in addition to the shortcode function below.

If you have read this far, perhaps you should add our lonely Google+ page to your circles…

Copy and paste the WordPress function into your theme's functions.php file or, if you sensibly have one installed, your custom functions plugin.

If you require shortcode to work in a sidebar widget, you'll have to enable the functionality with a filter. If you're using our custom functions plugin, you'll have that feature enabled by default.

Shortcode Attributes

id

The id is your Google+ ID number. While it accepts a profile URL you’re always better off using the ID in case the profile URL changes format.

type

The type is either author or publisher. If using a page, use the latter.

size

The size of the button is either small, medium, or large.

annotation

The annotation is the count bubble next to the follow button. It can be h (horizontal), v (vertical), or n (none).

align

Alignment can be left, center, or right. Will default to center.

p

To wrap your button in paragraph tags, use p="1". Paragraph tags will only be applied if the button is centered.

Download the Shortcode

Download the shortcode function here .

Shortt URL for this post:

Leave a Reply

Your email address will not be published. Required fields are marked *