WordPress: Social Bookmarking

Wordpress Social Bookmarking

WordPress is the tool of use of an increasing number of people, be it a developer, clients or just blog enthusiasts. If you fall into one of this categories you should think in optimization your WordPress experience. One way to do that is insert more functionalities into your website / blog. You should be thinking by now – Widgets! Well, widgets are one of the ways to achieve that, but do we really want to depend on widgets to implement all the features on our blog? You can, but you shouldn’t. It’s pretty obvious that after a certain amount of widgets you will see the loading time of your website increase accordingly.

This post falls exactly into this thematic that I hope to explore in future posts, WordPress functionalities without plugins. It seems harder than it is and even the typical Average Joe can do it. I haven’t yet explored much of the power to which you have access with a platform like wordpress and I can tell you that it’s simply amazing the stuff you can do with it.

Anyway, today is about Social Bookmarking, because it was exactly the part that I implemented into my theme today. For the ones that don’t know what the hell I’m talking about, by social bookmarking I mean the small links you can find in a lot of blogs to share the post with the rest of the world, i.e., Digg, StumbleUpon, Reddit… and Twitter, of course.

Social Links

What we want to achieve is what you can see in my blog, or like the picture below.

Social Links

The first thing to do is to write the html we need to make the horizontal menu. It’s a pretty simple unordered list (ul) with some list items (li) and a bit of CSS.

The HTML

Like I said, the html part is pretty simple. This is what I used to created the menu.

  <div class="social_links">
  <ul>
  <li></li>
  <li></li>
  <li></li>
  </ul>
  </div>

We’ll go into the structure of the links later. Right now focus on the list structure, as you can see it’s a pretty straightforward unordered list. The only thing to note is the wrapping of a div with a class (social_links).

The Link Structure

The key for having the social links… is to have them linking your post and title to the aggregation website of your choice (Digg, Delicious, etc..). For this you can check other blogs that makes use of social bookmarking and see the structure of the links (a bit of WordPress back-end knowledge comes in handy here), but for most of the link, you can find the appropriate href to use in a website like here.

As an example, the link structure of the Digg Bookmarker looks like this:

<li><a class="digg" href="http://digg.com/submit?phase=2&amp;url=<?php echo get_permalink() ?>&amp;title=< ?php the_title(); ?>">Digg</a></li>

The CSS

The next thing to do is to write some CSS to style the unordered list and the list items in it. This is the CSS i’ve used to style the Social Bookmarking Menu. I won’t go much further in explanations, but essentially the rollover effect in CSS is achieved by position the background image to a negative position, this means that in the same image you should have the normal state and the hover state, like this:

CSS Rollover Effect

The css code:

.social_links
{
clear:both;
height:16px;
margin-bottom:35px;
padding: 4px 0 15px 4px;
position:relative;
}

.social_links ul
{
position:relative;
float:left;
}

.social_links ul li
{
float:left;
list-style: none;
line-height: 16px;
padding-left: 8px;
}

.social_links ul li a
{
display:block;
padding-left: 24px;
padding-right: 4px;
height:16px;
color:#555555;
}

.social_links ul li a:hover
{
color:#f7bf29;
}

.social_links ul li a.digg
{
background: url("images/sl_digg.png") 0px 0px no-repeat;
}

.social_links ul li a:hover.digg
{
background: url("images/sl_digg.png") 0px -16px no-repeat;
}

Basically you just need to repeat the same for the other classes (just like I show here for the digg class). Nothing out of ordinary here, only thing to note is the use of the css background element position to achieve the rollover effect on the little social link icons.

The Icons

Last but not least, the icons to use in your links. I’ve used the excellent Social Network Icon Pack from Komodo Media but there are tons of other options out there, that you can use in your project. I’ll leave here a few as a starting point for your search.

Social Network Icon Pack

Social Network Icon Pack

Link: Komodo Media

Chrome Social Icons

Social Icons Chrome

Link: Chris Wallace

Social Bookmark Iconset

Social Bookmark Iconset

Link: Vikiworks

For more Icons check this article from Speckyboy Design Magazine or this one from Smashingmagazine.

Conclusion

That’s it! With this you should be able to have a nice looking Social Bookmarking menu without the need to use a plugin. Even better that not having to use a plugin is that you can customize it freely to suit your theme or personal taste. The limit is your imagination.

See you soon!

5 Comments
  1. Josh on September 11, 2009, 06:26

    I followed your link from another article on w3mag to see if you did indeed use Twitter in your bookmarking script…

    The issue with Twitter when manually inserting your bookmars is that you (assumably) are not caching the short URL for each post… This means that if you have a busy blog, then each and every time the page loads it will be requesting a short URL from whatever service you have set up for the Twitter link to use.

    This probably won’t be noticeable for relatively small blogs, but with a steady flow of traffic you will undoubtedly realize that this is a very heavy strain on your site.

    This is one of the many key reasons why I still think that using a WP plugin is far superior to manually inserting the links yourself.

    [ Reply ]
  2. greven on September 11, 2009, 08:15

    I didn’t think of that to be honest. I’m trying to optimize everything on my website but forgot about the code generated for twitter. The only way to solve it it would be trough caching the link. But now that you talk about it, since I’ve installed the Tweetmeme button I might as well just remove the twitter from the share menu and insert Mixx for example. Thanks.:)

    [ Reply ]
  3. Josh on September 11, 2009, 17:39

    No problem, I didn’t think of it at first either when I wrote the plugin… It wasn’t until the plugin got fairly popular and was used on a few “big” sites that they told me there was a problem.

    Once I looked into it, I realized what was going on.

    Good luck!

    [ Reply ]
  4. greven on September 11, 2009, 19:08

    Thanks Josh, your plugin is very attractive graphic wise. And I changed the code to generate the short link allready, since I’m using Tweetmeme already decided to pull that one off. :)

    Thanks for the advise. And to be honest I did noticed a shorter delay loading the pages after I started using that code. And you are right, one can’t noticed the impact of it, but when a page is hit by a burst of visits like StumbleUpon it can really stress your server.

    [ Reply ]
  5. Kokteyl on May 11, 2010, 14:26

    Thank you very much. I did it by courtesy of this page.

    [ Reply ]
Copyright © 2008 - 2010 Paintbits. All rights reserved. Hosted by WebHS.