User Tools

Site Tools


Custom Share Buttons

Share buttons make it easier for visitors to push your content on popular social networks. Adding them to your page can help your content go viral and better your word-of-mouth advertising.

If you want the standard Like/Share, Tweet, +1 buttons with counters and analytics, then you would do well to implement buttons using AddThis or a similar all-in-one service. But if you want standardized, fast-loading buttons that don't fill your pages with iframed garbage, we've got you covered here.

To get started, lay the groundwork:

And the code …


Add the following to your custom.css file.

#share-buttons ul, 
#share-buttons li {
	list-style: none;

#share-buttons ul {
	margin: 8px auto 0;

#share-buttons li {
	background: #333;
	float: left;
	font-size: small;
	line-height: 1.5em;
	margin-right: 8px;
	padding: 0px 8px;
	word-spacing: 4px;
	-moz-border-radius: 4px;
	-webkit-border-radius: 4px;
	border-radius: 4px;

#share-buttons a, 
#share-buttons a:hover {
	color: #fff;
	text-decoration: none;

@media only screen and (max-width: 600px) {
	#share-buttons li {
		margin-right: 16px;
	#share-buttons li span {
		display: none;
	} /* max-width: 600px */


To the phplugins.php file, add the following. In this example, we're attaching the buttons to the ttg_canvas_top hook, but feel free to put it anywhere.

This function creates Facebook “Share”, Twitter “Tweet”, Google Plus, Pinterest “Pin It”, and Email buttons.

function ttg_canvas_top( $style, $path ) { 
	echo '
	<div id="share-buttons" class="clearfix">
		<li class="share-via-facebook"><a href="' . urlencode(CURRENTPAGEURL) . '&title=' . urlencode(ALBUMTITLE) . '" onclick="; return false;"><i class="icon-facebook-sign"></i><span> Share</span></a></li>
		<li class="share-via-twitter"><a href="' . urlencode(ALBUMTITLE) . '+' . urlencode(CURRENTPAGEURL) . '" onclick="; return false;"><i class="icon-twitter"></i><span>  Tweet</span></a></li>
		<li class="share-via-googleplus"><a href="' . urlencode(CURRENTPAGEURL) . '" onclick="; return false;"><i class="icon-google-plus"></i></a></li>
		<li class="share-via-pinterest"><a href="' . urlencode(CURRENTPAGEURL) . '/photos/' . urlencode(PAGEIMAGE) . '&url=' . urlencode(CURRENTPAGEURL) . '&is_video=false&description=' . urlencode(ALBUMTITLE) . '" onclick="; return false;"><i class="icon-pinterest"></i><span> Pin It<span></a></li>
		<li class="share-via-email"><a href="mailto:?subject=' . urlencode(ALBUMTITLE) . '&body=' . urlencode('Hi,') . '%0D%0A' . urlencode('I thought this worth sharing. Enjoy!') . '%0D%0A%0D%0A' . urlencode(CURRENTPAGEURL) . '" onclick="; return false;"><i class="icon-envelope-alt"></i><span> Email</span></a></li>
} // END

Optional CSS

If you'd like, you can do more with styling. Here are just a few examples.


This should stick your buttons to the top, right corner of the page.

#page-body { position: relative; }

#share-buttons {
	position: absolute;
		top:   0;
		right: 0;

Color the Buttons

By assigning each <li> a unique class, we can assign colors to the buttons.

#share-buttons li.share-via-facebook {
	background-color: #385B93;

#share-buttons li.share-via-twitter {
	background-color: #4099FF;

#share-buttons li.share-via-googleplus {
	background-color: #D14836;

#share-buttons li.share-via-pinterest {
	background-color: #CB2027;

#share-buttons li.share-via-email {
	background-color: #333333;

Additional Services

If you'd like to add other serves to the bar, here are a few more options. Just copy the code and add to the list in the PHPlugins function above.


<li class="share-via-reddit"><a href="' . urlencode(CURRENTPAGEURL) . '&title=' . urlencode(ALBUMTITLE) . '" onclick="; return false;">Reddit</a></li>


<li class="share-via-delicious"><a href="' . urlencode(CURRENTPAGEURL) . '&title=' . urlencode(ALBUMTITLE) . '" onclick="; return false;">Delicious</a></li>


<li class="share-via-stumbleupon"><a href="' . urlencode(CURRENTPAGEURL) . '&title=' . urlencode(ALBUMTITLE) . '" onclick="; return false;">StumbleUpon</a></li>


<li class="share-via-linkedin"><a href="' . urlencode(CURRENTPAGEURL) . '&title=' . urlencode(ALBUMTITLE) . '&source=http://' . $_SERVER["SERVER_NAME"] . '" onclick="; return false;"><i class="icon-linkedin-sign"></i><span> LinkIt</span></a></li>


<li class="share-via-tumblr"><a href="' . urlencode(CURRENTPAGEURL) . '&t=' . urlencode(ALBUMTITLE) . '" onclick="; return false;">Tumblr</a></li>


<li class="share-via-posterous"><a href="' . urlencode(CURRENTPAGEURL) . '" onclick="; return false;">Posterous</a></li>
custom_share_buttons.txt · Last modified: 2013/06/05 01:12 by admin