How to Add Attractive Social Bookmarking Icons to WordPress Theme

by Ishan · 33 comments

UPDATE: After moving to Thesis theme, we no longer use this method for social bookmarking, but it can still work for you.

Social Bookmarks are must have for any blog. They let readers share the posts which brings traffic and new readers.

There are lot of plugins that add social bookmarks to WordPress but having custom Social Bookmarks has its own advantages.

Why? Because, they are eye catching and unique . You have full control over their appearance and the images that will be displayed.

Take a look at the bookmarking icons we use:

social-icons

In this tutorial, we will be adding custom social bookmarking icons to your WordPress blog just like the ones above.

This tutorial involves editing theme files. So, make sure you have backup of your theme before proceeding.

There is a Blogger version of this tutorial!

What we Need?

  1. Simple Twitter Link: A free plugin that generates short links for posts. We will need it for "Tweet This" button.
  2. Social Icons: You will need to get social bookmarking icons for services included in this tutorial(or others if you want to include).

Finding and Uploading Icons:

While hot-linking to images will do the job, its better to upload images for fast access. You can choose any type of icons you want, just make sure they are of same size!

Here are 5 Icon Packs you can use on your blog(links will open in new tab):

  1. Social Icons set from DryIcons.
  2. Heart Icon Set from Smashing Magazine.
  3. 3-d Social Bookmarking Icons.
  4. Web 2 Icons from FastIcon.
  5. Circle Social Bookmars from FastIcon..

Please note that some of these Iconsets may require to give credit to Original Creator, so please make sure you read their Terms of Service

Styling

In WordPress, go to appearance --> Editor. Stylesheet (style.css) is open by default. At the end of this file, add the following lines of code:

#Social{
background: #d4e2eb;
border: 1px solid #DDD;
padding: 5px;
margin: 5px;
}

You can edit color and borders to fit your theme. You can use I like Your Colors(opens in new tab) to extract colors from your design.

Code to Display Icons:

Here is the code that will display icons:


<DIV id="Social" align="center">

<TABLE border="0"><TBODY><TR><TD width="68">

<CENTER> <A href="http://del.icio.us/post?url=<?php echo the_permalink(); ?>&title=<?php the_title(); ? >"><IMG src="http://bloggingwithsuccess.net/wp-content/uploads/2009/02/delicious_48x48.png" alt="Add To Delicious" />Add to Del.icio.us </A> </CENTER></TD><TD width="68"> <CENTER> <A href="http://digg.com/submit?url=<?php echo the_permalink(); ?>&title=<?php the_title(); ? >"><IMG src="http://bloggingwithsuccess.net/wp-content/uploads/2009/02/digg_48x48.png" alt="Digg This post" />Digg This Post</A> </CENTER></TD><TD width="68"> <CENTER> <A href="http://www.stumbleupon.com/submit?url=<?php echo the_permalink(); ?>&title=<?php the_title(); ? >"><IMG src="http://bloggingwithsuccess.net/wp-content/uploads/2009/02/stumbleupon_48x48.png" alt="Stumble this post" />Stumble This Post</A> </CENTER></TD><TD width="68"> <CENTER> <A href="http://technorati.com/faves?sub=addfavbtn&add=http://bloggingwithsuccess.net" rel="nofollow"> <IMG src="http://bloggingwithsuccess.net/wp-content/uploads/2009/03/ technorati_48x48.png" alt="Fave on Technorati" />Fave on Technorati</A> </CENTER></TD><TD width="68"> <CENTER> <?php if (function_exists('simple_twitter_link')) : ?> <A href="<?php simple_twitter_link('Reading: %title% %url%'); ?>" rel="nofollow"> <?php endif; ?> <IMG src="http://bloggingwithsuccess.net/wp-content/uploads/2009/03/twitter_48x48.png" alt="Tweet This" />Tweet This</A> </CENTER></TD></TR></TBODY></TABLE> </DIV>

Replace image URLs with your own uploaded image URLs as we have hotlink protection and images won't be displayed on your blog with the above code.

Tweet This button needs Simple Twitter Link plugin installed, otherwise no link will be there.

Here is a quick overview of the php functions used:

<?php echo the_permalink(); ?>

Gets the permalink of post.

 <?php the_title(); ?>

Gets the post title.

<?php simple_twitter_link('Reading: %title% %url%'); ?>

Makes a link to Twitter which when clicked, takes reader to Twitter home with "Reading: -post title- -short-url-" in Status message.

Adding More Services

The above code includes links to Delicious, Digg, StumbleUpon, Technorati and Twitter.

For other services, you will have to compare the code to make bookmark button using these steps:

I am taking reditt.com for this example. However, you can apply it these steps to any service available.

1. Copy a submit URL generated by any Bookmark service from page. I copied following URL from ShareThis button for this post:

http://reddit.com/submit?url=http%3A%2F%2Fbloggingwithsuccess.net%2F%3Fp%3D2701&amp;title=How%20to%20Add%20(attractive)Social%20Bookmarking%20Icons%20to%20WordPress%20Theme%3F

2. Look for the Post URL and Title in the link. In this case, they are after url= and title= for Reditt.

3. Replace Post URL with following php code:

<?php echo the_permalink(); ?>

This code generates the URL of post reader is viewing.

4. Replace Title with following code:

 <?php the_title(); ?>

This code will generate the post title.

5. Finally, your Bookmark URL will look like following:

 http://reddit.com/submit?url=<?php echo the_permalink(); ?>&amp;title=<?php echo the_title(); ?>

This way, you can create links to any bookmarking website.

Adding Code to Theme:

This code has to added to theme so that it is displayed after every post/page. I will be covering single post, pages and homepage.

Home Page:

Go to Appearance -> Editor and open index.php page. Now, look for following code in your theme:

<?php if (have_posts()) : while (have_posts()) : the_post(); ?>

Do not place code after it. Instead, look for first php endwhile tag. It should look like this:

<?php endwhile; else: ?>

Place the code above it. This will add icons to all posts on homepage.

Single Posts:

To add icons to single posts, go to Appearance -> Editor and open single.php file. Look for following code in it:

<?php the_content(); ?>

the_content tag can have different attributes assigned to it in different themes. Do not worry about anything inside brackets, just look for php the_content

This code tells WordPress to place content. We want our icons after this, so place code next to it.

Pages:

For pages, go to Appearance -> Editor -> Page.php and repeat steps as with single post.

Plugin Interference:

If you useplugins to add stuff after your posts, the plugins will place everything before the bookmarks.

Only thing you can do to solve this is check if your plugin supports manual placement. Many plugins let you place their content manually with php code and you will have to place that code after the bookmarks.

We use Yet Another Related Posts plugin and it was displaying related posts directly after post before Bookmarks. If you too use it, just go to Options and uncheck "Automatically display related posts?". Now, add this code to call the plugin after social bookmarks:

<?php related_posts() ?>

You will have to refer to documentation of  plugin to find right code.If your plugin does not allow manual placement, you are stuck with the display!

Demo:

Here are the working demos that I created by using exact code in this post:

You are only limited by creativity. No need to stay with the code I used, you know where to place code, so go no and try something new and share it here with us!

If you liked this post, consider Stumbling or Saving to Delicious.

Get Blogging With Success Newsletter:

Subscribe to our Newsletter to get freebies and exclusive blogging tips.

Name
Email

0saves
If you enjoyed this post, please consider leaving a comment or subscribing to the RSS feed to have future articles delivered to your feed reader.
4 Reasons For Subscribing
  • Get Full Posts Delivered Directly To Your Inbox.
  • Get Exclusive Freebies For Subscribers.
  • No "Buy This, Buy That" Mails!
  • 100% Privacy. Your EMail Address Will Never Be Shared With Any Third Party.
About Writer [Blogging With Success]About Author Hi, I am a 18 year old Blogger from India. I am very passionate about blogging and also co-founder of Blogging With Success. I write about general blogging tips and WordPress. You can read other posts by me here.If you need help, feel free to contact anytime!

Leave a Comment

CommentLuv Enabled

{ 30 comments… read them below or add one }

Creative Junkie May 1, 2009 at 6:13 PM

YAY! It’s here!

But OMG … I’m going to have to read this over and over to fully understand it. Code and I are not friends. At all.

I’m so excited you posted this! Such a fantastic tutorial and resource for bloggers at every level – thank you!

Reply

Mr. I May 1, 2009 at 6:28 PM

Took some time but finally, I got it in readable form. Hope it helps you. Waiting to see new social bookmarks on your blog!

Reply

Creative Junkie May 1, 2009 at 7:44 PM

There’s an interesting discussion going on over at BlogCatalog about social bookmarking today: http://www.blogcatalog.com/discuss/entry/why-i-got-rid-of-social-media-buttons

What are your thoughts?

I swear, blogging just gets more and more confusing with each passing day.

Reply

Mr. I May 1, 2009 at 8:49 PM

I will still go for better user(and visual) experience which custom icons offer. SEO industry is based on predictions and noone can say definite thing about it! Go on, add icons, I have these, ProBloger has these, top blogs have these, do not worry!

Reply

Ricky Peterson May 1, 2009 at 8:04 PM

Thanks a ton for such a detailed information on adding these icons. After reading this post i have just implemented all of Icons on my blog. I appreciate your efforts to share such a vital information on your blog. There is a saying the more you share more you earn.

Reply

Mr. I May 1, 2009 at 9:05 PM

Thanks for Compliment. I guess you forgot to add Title to Reditt link on posts.

Reply

Ruchi May 1, 2009 at 10:45 PM

Great Tutorial , I will follow it soon .

Reply

magsmadison May 3, 2009 at 12:28 AM

This is great. I really want to add these links to my blog. Will any of it work in blogger?

Reply

Mr. I May 6, 2009 at 2:56 AM

These use some WordPress functions and will not work in blogger.

Reply

fahim May 6, 2009 at 10:56 PM

hey borther please explain
first i have to add a plugin tweet ok than add some code to style shee t and
the codes which you provide in the section of Code to Display Icons:
in which file i have to put it header ,style shee footer where please tell me or give me step by step guide
please brother help me

Reply

Mr. I May 6, 2009 at 11:21 PM

I will send details in email as comment will get too long and WP parses code!

Reply

Ruchi May 16, 2009 at 10:01 PM

Finally I have applied the icons to my site, Thanks Again for writing such a great tutorial.

Although there is one small problem in the reddit link which you have formed in the above article.

Instead of “http://reddit.com/submit?url=&title=”

It would be
Instead of “http://reddit.com/submit?url=&title=”

That is instead of the_permalink() it would be the_title() as we are submitting title.

Reply

Mr. I May 16, 2009 at 10:35 PM

Thanks for notifying! I will update the tutorial!

Reply

Rahul May 17, 2009 at 6:15 PM

this is for me i need to add social bookmarking tabs in my blog.

Reply

Mr. I May 17, 2009 at 6:41 PM

Rahul, these will only work on WordPress. For blogspot, you can use Share this widget ( http://sharethis.com )

Reply

Tampa Telecommunication May 20, 2009 at 4:00 PM

Good post. I will add social bookmarking icon on my blog. Thanks for helpful information.

Reply

SBA May 20, 2009 at 5:47 PM

You may have left the wrong site link( seems to be an ad, I removed link). Let us know when you add bookmarks to your blog so we can visit.

Reply

Mukund May 26, 2009 at 11:04 PM

You have done a wonderful job by posting this! One of my fellow blogger said, it is really a useful tip. I have done the same job as u did, but for bloggers(blogspot) in my blog. You may check that out. It is quite simple.

Reply

SBA May 27, 2009 at 6:44 AM

I think I sent you here from Blog Catalog — glad you like it. Your version is similar (without Twitter), using text links and vertical separators instead of large icons. I was not able to see the actual links on your blog, just read the html in the post.

Reply

mk July 4, 2009 at 11:33 PM

thanks, this will surely aware all bloggers in the field of applying good bookmarking icons

Reply

Jason July 12, 2009 at 9:45 AM

Anybody have a list of the submission links for all the social networking sites? I found most of them, but cannot for the life of me find the links for flickr and feedburner.

HALP PLEASE!!!

Reply

SBA July 12, 2009 at 5:32 PM

Although Flickr.com is a social network, you need to have your photos on their site (start a photo stream) for people to bookmark it as their favorite or leave comments on your image at Flickr. So start your account. Since there are no comments on your website, you can add the flickr link for people to go there and mark favorites or comment. Point them to your album with a text link at the top of your website.

Feedburner is not a true social network. You need to have a account, and put the subscribe button on your website! Then people can sign up for your posts as you publish them —but you don’t have a blog!!!! ???

Reply

Atul July 12, 2009 at 11:59 PM

great tutorial.. will srching similar to this

Reply

fourposter beds July 13, 2009 at 10:04 AM

I was searching for such tutorial it is very important stuff for me. social bookmarking icon is very important for any blog.

Reply

SBA July 13, 2009 at 5:41 PM

And where are you hiding your blog? I can’t find it…

Reply

Liz July 13, 2009 at 4:23 PM

I know how important those icons for social bookmarking are to be on my blog… no matter how hard I try to understand this thing , it’s like I’m reading at a blank page! I will have my webmaster check out this tutorial

Reply

BrendonA July 22, 2009 at 3:04 PM

I think Wordpress users can just install the Sociable plugin which includes more than 50 social bookmarking sites for you to choose from. Quick and easy without much hassle.

Reply

Joanne August 8, 2009 at 6:00 PM

Hi,

Thanks, your step by step tutorial is exactly what I am looking for. Although by using the ShareThis, AddThis or Sociable plugin is less troublesome, I would like to add the buttons manually as I can place more attractive and eye- catching icons.

Reply

bob October 5, 2009 at 1:45 AM

Thanks for the information,it will come in quite handy for building backlinks to my site. Keep the info hot this helps people with business websites.

Reply

SBA October 5, 2009 at 2:00 AM

Okay, but where is your WordPress site? (I removed the link you left since it’s a search portal). Let me know when you implement the bookmarking icons and I’ll visit.

Reply

{ 3 trackbacks }

Previous post:

Next post: