How to add Social Media Buttons in WordPress

by Devesh | Join Ana on Google+ Here



social media how to add buttons

Just follow directions...

This is a guest post by Devesh of Technshare.com and Blokube.com.

WordPress is one of the best platforms for blogging and has several advantages.

Because of its popularity, its support community is awesome. You will find various tutorials over internet, which will help you to get started with WordPress.

In this post, we’ll be adding buttons to our WordPress theme to allow visitors to easily submit the current blog post to social bookmarking sites like Twitter, Facebook, Blokube, Delicious, SERPd, Digg, StumbleUpon, and Blogengage.

Note from Ana: there are many reasons I think you should consider adding social media buttons directly to your theme code, rather than using a plugin, like

  • no more incompatibility and crashed blogs;
  • improved site speed;
  • you can choose what buttons you would like, what you want them to look like, what order you want them in, etc.

If you need help installing them on your site, contact Dev.

Adding Simple Buttons

Adding simple buttons is very easy.

Step 1. First of all download all the icons from here http://icondock.com/free/vector-social-media-icons

Step 2. Now just add these codes inside a loop (single.php file) and you’re ready to go.

<div>
<a rel="external nofollow" href="http://www.facebook.com/share.php?u=<?php the_permalink(); ?>" title="Share with your friends on Facebook"><img src="<?php bloginfo('template_directory'); ?>/uploads/icons/facebook.png" width="32" height="32" border="0" alt="Share with your friends on Facebook" /></a>
    <a rel="external nofollow" href="http://del.icio.us/post?url=<?php the_permalink(); ?>&title=<?php the_title();?>" title="Bookmark this post at Delicious"><img src="<?php bloginfo('template_directory'); ?>/uploads/icons/delicious.png" width="32" height="32" border="0" alt="Polariod Delicious Icon" /></a>
<a rel="external nofollow" href="http://www.stumbleupon.com/submit?url=<?php the_permalink(); ?>&title=<?php the_title();?>" title="Stumble this post"><img src="<?php bloginfo('template_directory'); ?>/uploads/icons/stumbleupon.png" width="32" height="32" border="0" alt="Polariod StumbleUpon Icon" /></a>
<a rel="external nofollow" href="http://digg.com/submit?phase=2&url=<?php the_permalink(); ?>&title=<?php the_title();?>" title="Digg this post"><img src="<?php bloginfo('template_directory'); ?>/uploads/icons/digg.png" width="32" height="32" border="0" alt="Polariod Digg Icon" /></a>
<a rel="external nofollow" href="http://www.mixx.com/submit?page_url=<?php the_permalink(); ?>&title=<?php the_title();?>" title="Mixx this post"><img src="<?php bloginfo('template_directory'); ?>/uploads/icons/mixx.png" width="32" height="32" border="0" alt="Polariod Mixx Icon" /></a>
<a rel="external nofollow" href="http://www.linkedin.com/shareArticle?mini=true&url=<?php the_permalink() ?>&title=<?php the_title(); ?>&summary=&source=<?php bloginfo('name'); ?>" title="Share this post on linkedin"><img src="<?php bloginfo('template_directory'); ?>/uploads/icons/linkedin.png" width="32" height="32" border="0" alt="Share with your linkedin groups" /></a>
<a rel="external nofollow" href="http://technorati.com/faves?add=<?php the_permalink(); ?>" title="Fav on Technorati"><img src="<?php bloginfo('template_directory'); ?>/uploads/icons/technorati.png" width="32" height="32" border="0" alt="Fav on Technorati!" /></a>
<a rel="external nofollow" href="http://reddit.com/submit?url=<?php the_permalink(); ?>&title=<?php the_title();?>" title="Reddit this post"><img src="<?php bloginfo('template_directory'); ?>/uploads/icons/reddit.png" width="32" height="32" border="0" alt="Reddit this post" /></a>

Step 3. Add this code in style.css

.share_care {width: 634px; padding-left:0px;}
.share_care a {background-color:none;}
.share_care img {background-color:none; border: none; margin-right:0.8em;}

Adding Share Count Buttons

Most of the share counts are a piece of JavaScript that you must retrieve from the social media service.

Paste all these codes inside a loop, most likely in your single.php file.

Twitter

<a href="http://twitter.com/share" data-count="vertical" data-via="wpkube">Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script>

FaceBook

<a name="fb_share" type="box_count" href="http://www.facebook.com/
sharer.php">Share</a><script src="http://static.ak.fbcdn.net/connect.php
/js/FB.Share" type="text/javascript"></script>

Blokube

<script type="text/javascript" src="http://www.blokube.com/evb/button2.php"></script>

Delicious

Go to header.php on your WordPress dashboard and insert the below code within </head>.

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script type="text/javascript" src="http://delicious-button.googlecode.com/files/jquery.delicious-button-1.0.min.js"></script>

Now go to single.php and paste this code

<div style='float:right; margin-right:10px;'>
<a  href="http://delicious.com/save">
   <!-- {
   url:"<?php the_permalinkundefined) ?>"
   ,title:"<?php the_titleundefined); ?>"
   ,button:"wide"
   } -->
   Save on Delicious
</a>
</div>

Source

Digg

<script type="text/javascript">
(function() {
var s = document.createElement('SCRIPT'), s1 = document.getElementsByTagName('SCRIPT')[0];
s.type = 'text/javascript';
s.async = true;
s.src = 'http://widgets.digg.com/buttons.js';
s1.parentNode.insertBefore(s, s1);
})();
</script>
<a href="http://digg.com/submit?url=<?php the_permalink(); ?>"></a>

StumbleUpon

<script src="http://www.stumbleupon.com/hostedbadge.php?s=1&r=<?php the_permalink(); ?>"></script>

Serpd

<script type="text/javascript" src="http://www.serpd.com/index.php?page=evb"></script>

Adding floating buttons

Note from Ana: Floating buttons are what you see to the right of this post. When you scroll up or down, the buttons remain visible at all times.

For Thesis Users

For those of you who are using Thesis theme, like Traffic Generation Cafe does, add this code in the custom_functions.php file to show twitter, facebook, blokube, stumbleUpon button

/* ------------------------*/
/* Social Floating Buttons*/
/*--------------------------*/
function sharepost() {
if (is_single()) { ?>
<div>
<div><script type="text/javascript" src="http://www.blokube.com/evb/button2.php"></script></div>
<div>
<a href="http://twitter.com/share" data-count="vertical" data-via="tnsblog">Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script>
</div>
<div>
<script src="http://www.stumbleupon.com/hostedbadge.php?s=5"></script>
</div>
<div>
<a name="fb_share" type="box_count" href="http://www.facebook.com/sharer.php">Share</a><script src="http://static.ak.fbcdn.net/connect.php/js/FB.Share" type="text/javascript"></script>
</div>
</div>
<?php
}
}
add_action('thesis_hook_after_headline', 'sharepost');

Add this code in style.css

/* Social Floating Buttons */
.sharepost{
float:left; border:1px solid #737373; margin-right:20px; top: 240px; position:fixed; background:#FFF; margin-left:-105px; width:64px; z-index:0
}
.sharer{
padding: 6px;
border-bottom: 0px solid #e8e8e8;
}
.sharer-fb{
padding: 6px;
padding-bottom:2px;
margin-bottom:1px;
border-bottom: 0px solid #e8e8e8;
}

For non-Thesis Users:

Since every theme has different functions, it is better to use a plugin:

  1. Smart sharing plugin - This plugin adds a scrolling box with social media icons on single post pages, so as your reader scrolls down the page, they will continuously see the share button.
  2. ShareBar Plugin - Sharebar adds a dynamic and fully customizable vertical box to the left of a blog post that contains links/buttons to popular social networking sites.
  3. Digg Digg - All-in-One social voted count buttons.

Do you have any other social media buttons that you would like to add? Let me know, and I can get the codes here.




{ 36 comments… read them below or add one }

Ari Herzog from New Media Explorer

Waitasec, you’re not using the Digg Digg plugin to power the floating buttons on the right? That’s Thesis code? (You don’t indicate dates on your comments so I have no clue how old this post is.)
Ari Herzog invites you to read: Introducing Stephen Tiano: Monday Muse #2My Profile

Reply

Ana Hoffman

My buttons are based on Sharebar plugin, but they are hard-coded into my Thesis framework, Ari.

Reply

Adrienne from Whole New Mom

Hi. I am going to have to try this. I would love to get RSS and email subscribe buttons to float as well, but mainly I would really like Pinterest w/ count button on the floating bar. Thanks in advance!

Reply

Ana Hoffman

You are welcome, Adrienne.

You can certainly add those buttons as well.

Reply

Adrienne

Would you be able to help with getting the codes for those - especially for:
the Pinterest with count button?
-Stumble Upon
and Facebook with count button.

Thanks in advance!

Reply

Devesh from WordPress Marketing

Hey Adrienne,

Yes, I can help you with adding those buttons. It wouldn’t be an hard step ;) .

Just sent you an quick mail.

-Dev
Devesh invites you to read: How to Create Event Registration Forms for WordPress Using 123ContactFormMy Profile

Reply

Sergio Felix

Hey Ana,

I know this is a guest post but I know you got this one:

What about the related posts rectangle showing at the end of every post?

The one with the round courners, what is that?

Thanks in advance,

Sergio
Sergio Felix invites you to read: How To Create Your First Video: Patrick Griffin InterviewMy Profile

Reply

Ana Hoffman

That one is custom-made for my blog, Sergio, and I am actually getting rid of it. LOL

I know it looks nice, but it’s useless from reader’s point of view; no one clicks on those links.

Reply

Mark from Getting Started With

I take your point about adding the buttons directly to the code instead of using plugins, although I prefer to stay away from code if possible. That’s one of the reasons I started using WordPress in the first place. For me the biggest issue with plugins is the effect on site speed, as you mentioned. I’ve recently started using a plugin called W3 Total Cache (thank you Mavis Nong), which improves the speed that your blog pages load. Having said that, I’ve already got quite a lot of plugins installed and even with W3 Total Cache it’s possible I may get to the point where speed becomes a problem. I’ll monitor things, and consider adding code if necessary. The instructions in this post are very clear, and adding buttons this way seems really easy. Many thanks for sharing.
Mark invites you to read: WordPress Themes Revisited - Woo ThemesMy Profile

Reply

Ana Hoffman

You’re welcome, Mark.

It is really easy to add the buttons using this method, so give it a try when you decide to do it.

Reply

Kimberly Castleberry

Hey Ana & Devesh, this looks like exactly what I was scouting the web to find for thesis! Thanks for the great stuff all the time!
Kim
Kimberly Castleberry invites you to read: Making Sense of Facebook’s New InsightsMy Profile

Reply

Kimberly Castleberry

Oddly, for thesis, this wanted to get jammed up inside my content box. Even when it was the first element in my custom function file. I ended up switching to the code from fourblogger and and now working to modify that to be share-counter buttons rather than just icons. I’m not sure what the differences in layout details amount to but their code floats correctly for me. Its worth noting that I am developing atm on a highly customized site, and conflicts of course are likely to be to blame.
Kim
Kimberly Castleberry invites you to read: Making Sense of Facebook’s New InsightsMy Profile

Reply

Patricia

Hi Devesh

Will get my techie friend to check out this post. I have no idea about all this but you give great instructions. Thanks for sharing this informative post Devesh. Much appreciated.

Patricia Perth Australia
Patricia invites you to read: So Little Time- So Much To DoMy Profile

Reply

Devesh

Hey Patricia,

That’s great to hear and glad you like it too.
Thanks for commenting patricia.
Devesh invites you to read: WordPress Cyber Bundle 579 worth of value for 30My Profile

Reply

Kareem Williams

I love this post Ana, i had a hard time getting the buttons on my blog. So you doing this post will be very very powerful for people to follow. thanks A million girl.
Kareem Williams invites you to read: Successful Blogging Webinar- My Successful Blogging Secrets Revealed Tonight!!!!!!!!!My Profile

Reply

Devesh

Glad you like the post Kreem. Thanks for commenting.

Have a great day!

Reply

Jym

Hey Devesh and Ana,

Very useful information, and a problem I recently solved using a plugin. But I’m going to look at using your code since, as far as I’m concerned, the less plugins, the better! The customizable control is a definite plus as well.

Thanks Ana for showcasing this tech-wizardry, and thanks Devesh for being the wizard - we need people like you!

Jym
Jym invites you to read: Ready- Fire- Aim! – Taking Action part 1My Profile

Reply

Devesh

Hi Jym,

Exactly ! Less plugins is much better.

Thanks for the awesome comment jym. If you need any help about adding buttons on your blog then don’t hesitate to contact me.

Reply

Hector Cuevas

Devish.. what an awesome resource man - I’m definitely saving this for future reference..

thanks bro
talk soon
Hector
Hector Cuevas invites you to read: 7 Reasons Why You Should Build A Strong Personal Brand Plus 2 TipsMy Profile

Reply

Devesh

Hi Hector,

Glad you like it bro. Thanks for the awesome comment.

I really appreciate your support.

Reply

Brankica

Oh, I love when I can find all in one place like you posted it here.
Codes and everything, all I need to do is copy and paste.
I am always looking for more “make up” for my blogs and I love the buttons you are using so I might give it a try.
I love the big coffee “buttons” on the left side of the post - so unique.
Anyway, thanks for the tips, just what I needed.
Brankica invites you to read: Twiends review One more Twitter toolMy Profile

Reply

Devesh

Hi Brankica,

That’s great to hear. Thanks for the nice comment. Much Appreciated.
Devesh invites you to read: Black Friday WordPress Deals – Big SavingsMy Profile

Reply

Mavis Nong

Hi Ana and Devesh,

Thanks for sharing this. I installed the ShareBar plugin a couple of weeks ago but it seems to work only when I’m using google chrome :( I will try the other ones you have recommended here.

All the best,
Mavis Nong
Mavis Nong invites you to read: Focused Magnetic Energy Attraction Marketing SuccessMy Profile

Reply

Devesh

Hi Mavis,

You should try smart sharing or digg digg plugin for floating buttons.

Thanks for commenting. Have a great day.
Devesh invites you to read: 8 Most Wanted Hacks for Thesis WordPress ThemeMy Profile

Reply

Mavis Nong

Hey Devesh,

I have installed Smart Sharing and it works like a charm! :)

Thanks very much,
Mavis
Mavis Nong invites you to read: Blog Traffic- How To Attract Even More Traffic With This Cool Plugin…My Profile

Reply

Laura Crest

Thank you for this most helpful info! Was dealing w/just this issue w/my own site yesterday - this post was most timely and useful. Kudos and thanks, Devesh and Ann!

Reply

Devesh

Glad you found it helpful.

Thanks for the nice comment Laura. Much Appreciated.

Reply

Sheila Atwood

Devesh,

These look like some great plugins. I do like how Anas moves up and down the page. My question is about blog load time. Right now I am using onlywrie, it seems slow and I have seen complaints about load time of other share buttons. How do you think these compare?
Sheila Atwood invites you to read: The Weekend Web – BacklinksMy Profile

Reply

Devesh

Glad you like it. Smart Sharing Floating plugin works great and it will not going to slow your blog. If you’re using thesis then you can add the floating buttons manually.

Thanks for commenting Sheila.

Reply

Amy Spreeman

These instructions look pretty easy. Right now I am using the Add to Any plugin, plus a tweet button plus a Like button. Might be time for a change.
Amy Spreeman invites you to read: Cyber Monday- Top Seven Clicks for great dealsMy Profile

Reply

Devesh

Adding social media buttons is very easy! If you ever need any help about buttons then don’t hesitate to contact me.

Thanks for commenting.

Reply

Oliver Tausend

Hi Ana and Devish,

thanks for sharing your insights. I’m using DiggDigg now at the moment. As I am considering a change to Thesis, chances are I’ll change that in the near future.

Take care

Oliver
Oliver Tausend invites you to read: Twitter And Social Media- Ever Heard Of The Importance Of Weak Links My Profile

Reply

Jonathan Sweeting

I was thinking the same thing Oliver…
Jonathan Sweeting invites you to read: How To Get Endless Free Traffic to Your Sites all Day Long VideoMy Profile

Reply

Devesh

Yeah digg digg is a great plugin but i prefer image buttons more.

and thesis is really a great theme for WordPress.

Thanks for the nice comment Oliver.

Reply

Marcus Baker

Hi Devish and Ana,

Thank you for making the Smart Sharing Plugin available - just what I have been looking for! I was astounded to read of the improved sharing rates on your site since using it Devish.

~Marcus
Marcus Baker invites you to read: Tweet top Blog Posts in Your Niche on Autopilot for FreeMy Profile

Reply

Devesh

Hi Marcus,

That’s great to hear man. Smart sharing is a great plugin.

Thanks for the nice comment.

Reply

Leave a Comment

Commenting Policy STOP & READ: Do not use just keywords in "Name" field; you MUST leave a real name, if you want to see your comment approved. Thinking of dropping your link spam? Save the effort: your comment will NEVER show up on this blog.


CommentLuv badge

 

Check This Box to Get Access to My SEO Report and Exclusive Traffic Generation Tips.

 

TGC uses CommentLuv Premium, which allows you to use your real name and then @your keywords (maximum of 4 keywords). Click on the link above to get your own CL Premium - it's pretty awesome!

Previous post:

Next post: