Add social bookmarking icons to your sidebar without using widgets

As social bookmarking sites such as Twitter, Facebook and Linked in become more and more popular, these days, I find myself being asked to make adjustments to several WordPress websites by adding social bookmarking links and icons to the sidebar. After 2 such web updates this week, I was asked by a friend to send me the code so that they could add it to their site. So instead of doing the work and sending it to him, I thought I would share it with you all.

The following examples are just code snippets that you can add to your sidebar.php template file. These snippets will not work if your website use sidebar widgets. (That’s not exactly true, but it’s a bit more complicated.)

The first example is very simple and can be seen live on the kitsilano.ca website.

Kitsilano sidebar example

First you’ll need to edit your sidebar.php template and add the following lines of code:


<h2>Follow Us</h2>
<ul>
<li class="rss">
<a href="[insert your rss link here]">Get our Feed</a>
</li>
<li class="twitter">
<a href="[insert your twitter link here]">On Twitter</a>
</li>
</ul>

Next you can adjust the styling by adding this piece of code to your style.css


#sidebar li.rss {background:url(images/rss.gif) 0 50% no-repeat;}
#sidebar li.twitter {background:url(images/twitter.gif) 0 50%  no-repeat;}
#sidebar li.rss a, #sidebar li.twitter a {padding-left:20px;}

The icons will also have to be uploaded in your templates’ images folder. You can use your own icons or grab the ones that I’ve used by downloading the zip file.

The second example may look a bit more complex, but is just as easy and can be seen on the mudcreative.com sidebar.

Mudcreative Social Bookmarking example

First insert these lines of code in your sidebar.php:


<div id="social_media">
<h2>Follow Us</h2>
<ul>
<li><a href="[insert your link to linked in here]"><img src="<?php bloginfo('template_directory'); ?>/images/linkedin.png" alt="View our linked in profile" width="32" height="32" border="0" /></a></li>
<li><a href="[insert your link to twitter here]"><img src="<?php bloginfo('template_directory'); ?>/images/twitter.png" alt="On Twitter" width="32" height="32" border="0"></a></li>
<li><a href="[insert your link to rss feed here]"><img src="<?php bloginfo('template_directory'); ?>/images/rss.png" alt="Via our RSS feed" width="32" height="32" border="0" /></a></li>
<li><a href="[insert your link to facebook here]"><img src="<?php bloginfo('template_directory'); ?>/images/facebook.png" alt="On Facebook" width="32" height="32" border="0"></a></li>
</ul>
</div>

Next, add the following to your style.css


#social_media {
width:200px;
background:#F2F7F7;
border:1px solid #ACD0D1;
padding: 0 0 5px 0; margin-bottom:10px;
}
#social_media ul {list-style-type:none; margin:0 0 0 6px; padding:0;}
#social_media ul li {display:inline; padding: 0 6px 0 0;}

Depending on what your stylesheet already contains, you may need to make a few tweaks, but it should be pretty straightforward. Here is zip file with the code snippets and icons. Have fun.

4 Responses to “Add social bookmarking icons to your sidebar without using widgets”

  1. Mhairi says:

    This is a very useful post. Thanks for sharing. Its important for any company planning to use social media to make themselves accessible and this is a great way to do so.

  2. Louise says:

    I agree with Mhairi. I think it’s absolutely critical that all websites have social media icons today if you want your company to be perceived as progressive – provided that you are actually a SM participant, of course. Thank you for your excellent work on this for my site Christine.

  3. Dluzional says:

    Morning, and tend to agree with the above, and saying that
    Thanks for sharing this, not to many people seem to want to share anymore.

    Now..

    Would this code work for the header.php?
    or would that be an entirely different set of commands?

    I already have a header (yes that’s sounds as dumb as it looked when I typed it LOL)

    I have an rss icon in the upper left side of the header but it’s a “bookmark” icon and not the RSS feed icon.

    It would be nice to be able to put a twitter, rss and whatever other icon I would like into the header as opposed to the sidebar (which tends to get cluttered up not to mention size matters (wow never thought I’d be saying that)…LOL..

    Thanks in advance

  4. christine says:

    I don’t see any reason why you couldn’t put that info in the header or footer. It should work just the same.

    If you look at the challenge series website, you’ll see that I added the send to a friend, bookmark and icon for email in the header. You could easily use that principle for rss and twitter.

Leave a Reply