Home Blog Embed a Google+ Badge on Your Website With WordPress Shortcode or PHP

Embed a Google+ Badge on Your Website With WordPress Shortcode or PHP


A Google Plus badge is a feature rich way of converting visitors over to your Google Plus personal profile, page, or community. The badge will permit logged in users to add you to a circle directly from your website. The Google Page badge will make your website eligible for Google+ Direct Connect (enabling a feature in Search that’ll permit a user to add you to a circle).

While Google have a tool to manufacture the necessary code, shortcode gives the option of very easily effecting changes globally. It also provides your authors with a more uniform way of adding the feature.

This article will provide you with the necessary code to add either a Google Badge onto your WordPress website with shortcode.

The Result

The badge we use for BeliefMedia (a page we’ve never posted to) is rendered with the shortcode of [googleplusbadge landscape="1" id="101664805814849068242" type="page"]. The result:

The shortcode of [googleplusbadge id="101343022544296051888"] will display my personal profile in the (default) portrait mode.

The same profile in landscape looks like this:

Note that while a page profile badge presents the +1 option, the personal profile badge does not.

To demonstrate the dark skin, we’ll reference our neglected Flight Plus Page with the shortcode of [googleplusbadge id="112861932260007740384" width="273" theme="dark" type="page"]. The result:

Not very pretty! You may omit the tagline with the shortcode of tagline="0".

You may include a community badge with the shortcode of [googleplusbadge landscape="1" id="115758385206378551362" type="community"]. The result:

Note that the page type attribute of community must be defined if the badge is not for a personal or brand profile.

WordPress Shortcode

This function requires that Google's Platform JavaScript function be rendered on your page. You can download the function or plugin here.

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

There’s a large number of attributes but they should be considered ‘options’. Set your default values so your preferred badge can be rendered with just googleplusbadge.


The id is the ID or URL for your personal profile, page, or community.


The type is either person, page, or community. It must be defined.


The width of your badge. You may alter the width to between 180-450 pixels in portrait mode, and 273-450 pixels in landscape mode.


The theme is either light or dark. It is light be default.


The tagline in portrait mode can be removed with tagline="0".


The photo can be removed with photo="0" (not very reliable in our tests).


Use landscape="1" for landscape mode. Defaults to portrait.


Set the alignment of the div container by way of align="center" (default).


To wrap the badge in paragraph tags (the default behaviour) use p="1". If you choose not to use them, use p="0".


For community pages you may list the page owners with the attribute of owners="true".

PHP Function

Used outside of WordPress, the following may be used. The platform.js code is required.

Attributes should be passed to the function in the arguments array.


Title: Embed a Google+ Badge on Your Website
Description: Embed a Google+ Badge on Your Website With WordPress Shortcode or PHP.
Download: Shortcode (V0.2) | PHP Code (V0.2) | Plugin Page

Shortt URL for this post: http://shor.tt/2nPy


Please enter your comment!
Please enter your name here