Bin-Blog logoBin-Blog

Learn about the latest in Web Development – as soon as I do.

Adding Social Bookmarking Button in WordPress – Without Plugins

By • Mar 28th, 2009 • Category: PHP, Scripts, WordPress

Social Bookmarking

Many blogs have links to add the current post to various social bookmarking site like Digg, Reddit, Delicious, etc. This blog don’t have it – but my LinDesk blog does. This effect is achieved using wordpress plugins like…

For those who are new, this is part three of the Plugin Killer series. This series will show you how to duplicate the functionality of the a few wordpress plugins without having to install it using custom code in the wordpress theme. The earlier posts in this series are…

The Code

You can add social bookmarking button to your post by editing the single.php file in your theme. Go to the place in the file where you want the buttons to show up – then add this code at that location…

<a href="http://del.icio.us/post?url=<?php the_permalink() ?>&title=<?php echo urlencode(the_title('','', false)) ?>">del.icio.us</a>
 | <a href="http://digg.com/submit?phase=2&url=<?php the_permalink() ?>">Digg it</a>
 | <a href="http://reddit.com/submit?url=<?php the_permalink() ?>&title=<?php echo urlencode(the_title('','', false)) ?>">reddit</a>
 | <a href="http://www.stumbleupon.com/submit?url=<?php the_permalink() ?>&title=<?php echo urlencode(the_title('','', false)) ?>">StumbleUpon</a>

Of course, you don’t have to do it like that – a better way of doing it is by putting the links in a li/ul list and then styling it. The point is, you don’t need a plugin to do this.

Different Implementations

Another thing I would recommend is get the images – in the above code, I just used text links. If you get the favicons of the sites you’re linking to, it will look a lot nicer. Example (go to the end of the post). You can use bigger images as well – example. Or use some kind of effect – example(here the icons are a bit transparent by default – but when you hover over them, it shows up clearly – its completely opaque).

Here only the four big ones are given. You can find code for more social bookmarking sites elsewhere.


8 Responses »

  1. […] Adding Social Bookmarking Button in WordPress – Without Plugins … […]

  2. Niyaz PK says:

    I guess adding to single.php will make the links appear in single post pages only. This will not show up in the home page. right?

    Is there some place where if I edit it will appear everywhere?

  3. Anish K.S says:

    Binny can we include corresponding social network images by changing the code.

  4. Juegos says:

    Thanks for your help, thanks to your article i was able to place the social bookmarking buttons on my site.

  5. Joyd says:

    Also, you can change the html or php code to insert custom images.

  6. techsplurge says:

    Hey thanks i needed something like this cos the plugins out there don’t meet my needs.

  7. neha says:

    Hey thanks i needed something like this cos the plugins out there don’t meet my needs.

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>