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).
Note: Google+ is now deprecated. The post remains as a reference only.
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:
[googleplusbadge landscape="1" id="101664805814849068242" type="page"]
The shortcode of [googleplusbadge id="101343022544296051888"]
will display my personal profile in the (default) portrait mode.
[googleplusbadge id="101343022544296051888"]
The same profile in landscape looks like this:
[googleplusbadge id="101343022544296051888" landscape="1"]
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:
[googleplusbadge id="112861932260007740384" width="273" theme="dark" type="page"]
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:
[googleplusbadge landscape="1" id="https://plus.google.com/communities/115758385206378551362" type="community"]
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
.
id
id
is the ID or URL for your personal profile, page, or community.type
type
is either person
, page
, or community
. It must be defined.width
theme
theme
is either light
or dark
. It is light be default.tagline
tagline
in portrait mode can be removed with tagline="0"
.photo
photo="0"
(not very reliable in our tests).landscape
landscape="1"
for landscape mode. Defaults to portrait.align
align="center"
(default).p
p="1"
. If you choose not to use them, use p="0"
.owners
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.
Download
No longer available.