In some cases, you may want to add our apps in a specific location on your webpage other than the auto-placement done by the plugin. You may also want to set custom look/feel and settings for buttons on a particular page.
You can do this with the app Shortcode (which is WordPress' method for truncating content code for plugin developers) and paste it in the page template wherever you want it to appear.
How to Install Shareaholic in Specific Locations on WordPress Pages
STEP ONE - Get the code
- In the Shareaholic App Manager, click any of the Customize buttons for Related/Promoted Content or Share Buttons.
- The shortcode containing the app's unique id number is displayed at the bottom of the Edit panel.
- Copy this code.
- Locate the page template where you want to install our apps and paste the shortcode wherever you want the app to appear on the page (see below for detailed instructions).
Example Shortcode:
Share Buttons
[shareaholic app="share_buttons" id="xxxxx"]
Related/Promoted Content
[shareaholic app="recommendations" id="xxxxx"]
NOTE: You can also specify the id_name (location name) instead of the id number for both the Share Buttons and Related/Promoted Content shortcode snippets. For example:
[shareaholic app="share_buttons" id_name="post_below_content"]
[shareaholic app="recommendations" id_name="index_above_content"]
This can be very useful for multi-site installations and theme developers who would like to bundle Shareaholic directly into their themes.
STEP TWO: Customize what is Shared (optional)
You can tell Shareaholic what specific details to include when people share your content by adding "Data Attributes" within the shortcode. Right now, you can customize the page Title, Link and Summary using the following template:
Share Customizations
title="This is my Page Title"
summary="You can place your own description of the page here."
What is looks like in the shortcode
[shareaholic app="share_buttons" id="xxxxx" title="Title of the Page being Shared" link="http://www.TheURLtoShare.com/page.html" summary="This is a description of the page that will be shared."]
STEP THREE: Insert the Code
There are three methods you can use to manually insert our apps into your WordPress site. Select the method that meets your needs and follow the instructions provided.
- Add Shareaholic into your templates
- Add Shareaholic as a sidebar widget
- Add Shareaholic within select content
Templates
The most commonly used method for customizing app placement is to add the app directly into your theme's template. This ensures that our apps appear for all content where this template loads.
(I recommend any changes made to a theme be applied via a child theme. This allows you to customize the theme without actually modifying the default template files.)
How to access your template files
There is an editor built into your WordPress Admin that you can use to edit your page templates. You can locate it by going to Appearance > Editor.
You'll see a dropdown menu at the top-right where you can select which theme you would like to edit, and beneath this is a list of all files used to render the theme (templates and stylesheets).
When you select one of the files, it opens in the edit box to the left. Because themes and content layout vary from site to site, if you are having trouble determining which template files to modify, you may find this list helpful in identifying what each file does.
Once the appropriate file has been opened, you are likely to be a bit overwhelmed if unfamiliar with PHP. Don't let this intimidate you. At some point, most publishers will find themselves editing something in their theme, and first times are always scary. If you are working with a child theme (which you should be), don't worry about messing anything up. You can easily start over if something goes wrong.
Where to place the Shareaholic shortcode
In the edit box, scan the content of the file to see if you recognize any keywords that are indicative of where you are when viewing the template, such as entry or loop or comments. You can even use Google for help if you get stuck.
How to add the Shareaholic shortcode
To insert any of your Shareaholic configured apps into your template files, use the following structure:
<?php echo do_shortcode('[shareaholic shortcode]'); ?>
Example:
<!-- Shareaholic Share Buttons -->
<?php echo do_shortcode('[shareaholic app="share_buttons" id="xxxxx"]'); ?>
Note: If you don't see the updates right away, clear all caches in any caching plugins (e.g., W3 Total Cache, WP Super Cache) along with your browser's cache.
Adding our apps into your template is the most difficult manual insertion method, but it is often utilized with custom post types or when you would like to include our apps in the header or footer of your site.
Widget
In some cases, you may want to add our apps in your website sidebar.
- Click on Appearance > Widgets
- Edit an existing Text widget or drag and drop a new Text widget wherever you want the Share Buttons, Related Content or any other App to appear.
- Paste the Shareaholic shortcode directly into the widget Content box and click Save.
Note: If you don't see the updates right away, clear all caches in any caching plugins (e.g., W3 Total Cache, WP Super Cache) along with your browser's cache.
In Content
We do offer options to disable plugin features on individual pages and posts, and these controls work for content that uses your standard post and page templates (but not for custom post types) if the content is automatically placed by our plugin.
One of the shortcode features is that you can include it directly in a Page/Post edit box. Just switch to the Text tab and paste the shortcode anywhere within your content (e.g., above, below, middle).
Reasons to add Shareaholic directly into content
- You want to include our apps multiple times in a post
- You'd like to prompt readers to share multiple times in a post (good for longer posts)
- You may want to add Related Content in the middle of your post to encourage page surfing so that they'll stay on your site longer.
- You want multiple Share Button styles on the same page