How to add Google+, Facebook Share on Sharebar Plugin for WordPress

  • Sharebar

In the process of writing up a post about a bunch of WordPress plugins that I use and recommend, I decided to write about the Sharebar plugin in isolation of the others simply because (apart from the fact that it’s awesome), by default, it excludes some important social networks that deserve inclusion.

What is sharebar?

You’ll notice that I have a hovering bar to the left hand side of this page that renders ‘share buttons’ to various social networks. It ‘hovers’ at the top of the page as you scroll down a post – meaning that it’s always in view, and it’s always offering encouragement for your readers to share. If the page is resized below 1000px (default), the vertical bar (to the left or right of your page container) disappears and a horizontal sharebar appears under the post title.

I’ve seen about a dozen variants of this plugin (mainly paid premium products) – but Sharebar is excellent, and it’s free. I’ve recently installed it on at least 5 blogs.

Installation

Install and activate Sharebar as you would any other plugin. You can download sharebar directly from WordPress.org here.

Configuration

The plugin offers a number of social share buttons by default. For each social network there are two button options: one ‘large’ button that renders when the sharebar is to the left or right of your page container, and a ‘small’ button that will be displayed under your title should your page be wider than 1000 pixels.

sharebar plugin setup

There are a number of configuration options available via the ‘Settings’ tab that enables you to customise colour and presentation.

Adding additional buttons

The author has indicated via his ‘to-do’ list that he’ll add more buttons, but you’ll always want a different combinations of buttons that are included by default. The Google +1 button, for example, is not yet an option. However, the plugin does have functionality that permits you to add additional share buttons, assuming the button code is available from the platform you wish to add.

Adding the Google +1 Button to Sharebar

Google provides four button options via its +1 webmaster page.

Installation is easy on any ‘normal’ webpage.

<!-- Place this tag in your head or just before your close body tag -->
<script type="text/javascript" src="https://apis.google.com/js/plusone.js"></script>

<!-- Place this tag where you want the +1 button to render -->
<g:plusone size="tall"></g:plusone>

If we want to install this code into a WordPress blog, the first thing you will have to do, as per Google’s instructions, is add the JavaScript to the head of your blog. You’ll have to copy this code into your theme’s functions.php file or, if you have one, into a custom function file.

function google_plus_one_integration() {
	?>
<script type="text/javascript" src="http://apis.google.com/js/plusone.js"></script>
	<?php
}
add_action('wp_head', 'google_plus_one_integration');

Now you must add Google code for both a large and small button into a textbox that’s presented in the Sharebar button configuration options.

sharebar plugin for wordpress setup Google Plus share
Configuration Options for the Google +1 button

Note that I’ve used the tall and small options. Once updated, the Plus One button will be available for inclusion in the sharebar.

Adding the LinkedIn Share Button to Sharebar

LinkedIn also have a share button that enables readers to post information to their LinkedIn profile. As with the Google Plus button, it’s easily integrated into Sharebar. Navigate your way to the Sharebar options (under Settings) and click “Add New Button”.

For the small button you should use code for the horizontal count:

<script type="text/javascript" src="http://platform.linkedin.com/in.js"></script><script type="in/share" data-counter="right"></script>

For the big button – displayed when the sharebar is rendered to the right or left of the page – you’ll need to render the Vertical Count button:

<script type="text/javascript" src="http://platform.linkedin.com/in.js"></script><script type="in/share" data-counter="top"></script>

Your results will look like this:

sharebar plugin for wordpress setup facebook share

LinkedIn Button options

Alternative Facebook Share Button

The clever chaps at awe.sm have built an alternative share button for Facebook for those that want a button that looks a little different. It’s my preferred option because the native FB button tends to cause some formatting problems; it’s also highly configurable and integrates well with other services (such as Google Analytics).

For the big button, add:

<script src="http://widgets.fbshare.me/files/fbshare.js"></script>

For the small button, add:

<script>var fbShare = {
 size: 'small',
 }</script>
<script src="http://widgets.fbshare.me/files/fbshare.js"></script>

You can see the results of the alternative FB share button on the sharebar to the left of this page.

 

You can leave a response, or trackback from your own site.