Automatic Social Media Links

This would go inside the loop, probably underneath the_content(), probably in your single.php file.

// bookmark on Delicious
<a rel="nofollow" href="<?php the_permalink(); ?>&amp;title=<?php echo urlencode(get_the_title($id)); ?>" title="Bookmark this post at Delicious">Bookmark at Delicious</a>

// submit to Digg
<a rel="nofollow" href=";url=<?php the_permalink(); ?>" title="Submit this post to Digg">Digg this!</a>

// tweet on Twitter
<a rel="nofollow" href="<?php echo urlencode("Currently reading: "); ?><?php the_permalink(); ?>" title="Share this article with your Twitter followers">Tweet this!</a>

// submit to StumbleUpon
<a rel="nofollow" href="<?php the_permalink(); ?>&amp;title=<?php echo urlencode(get_the_title($id)); ?>" title="Share this post at StumbleUpon">Stumble this!</a>

// share on Facebook
<a rel="nofollow" href="<?php the_permalink();?>&amp;t=<?php echo urlencode(get_the_title($id)); ?>" title="Share this post on Facebook">Share on Facebook</a>

// submit to Blinklist
<a rel="nofollow" href=";url=<?php the_permalink(); ?>&amp;Title=<?php echo urlencode(get_the_title($id)); ?>" title="Share this post on Blinklist" >Blink This!</a>

// store on Furl
<a rel="nofollow" href="<?php echo urlencode(get_the_title($id)); ?>&amp;u=<?php the_permalink(); ?>" title="Share this post on Furl">Furl This!</a>

// submit to Reddit
<a rel="nofollow" href="<?php the_permalink(); ?>&amp;title=<?php echo urlencode(get_the_title($id)); ?>" title="Share this post on Reddit">Share on Reddit</a>


  1. User Avatar
    Permalink to comment#

    Awesome !

    This is an great collection of usefulness here.
    All the major links and codes we need to either use as-is or built or (sprite-powered ;-) ) GUI-version of it.

    Thanks !

  2. User Avatar
    Claude Gelinas
    Permalink to comment#

    Thanks for making these links available in a form any web publisher can understand — I’ll try to make my own, more customized, images to link with these social bookmarking sites!

  3. User Avatar
    Permalink to comment#

    I can’t get these to validate, anyone know what I might be doing wrong. This is the message I get,

    “general entity “t” not defined and no default entity”

    I’ve created a facebook share button on a wordpress blog.

  4. User Avatar
    Permalink to comment#

    Big Thanks to make it easy to include to our Coda App ;)

  5. User Avatar
    Permalink to comment#

    Nice post! Very helpful indeed!

  6. User Avatar
    Rahul Prasad
    Permalink to comment#

    Thanx a lot buddy.
    Isnt there any app which submit to these sites automatically with minimal interaction possible?

  7. User Avatar
    James Mark
    Permalink to comment#

    thanks to sharing social bookmarking button good post

  8. User Avatar
    Permalink to comment#

    Nice one ..

  9. User Avatar
    Kaushik Biswas
    Permalink to comment#

    Great! This is the way to do without any plugins :)

  10. User Avatar
    Permalink to comment#

    this nice code however all goes no to ready plugins its easy to be used

  11. User Avatar
    murtaza kanpurwala

    Wow dats great …….. no need of JS and plugins in wordpress

  12. User Avatar
    Jens Ahrengot Boddum

    Nice list – However the Twitter one doesn’t seem to work anymore.

    This one does: – And it automatically runs it through Twitters shortlink service as well..

  13. User Avatar
    MQ Hidayat

    to twitter, I prefer to use tweetmeme, because the count from sometimes invalid.
    thank you for this information.

  14. User Avatar
    Permalink to comment#

    Nice.. thanks, useful code.

  15. User Avatar
    Permalink to comment#

    You always have the best info. Thanks for all your sharing.

  16. User Avatar
    santé bien être
    Permalink to comment#

    very helpful ! thx :)

  17. User Avatar
    ilana mullin
    Permalink to comment#

    this is great! finally a way around those damn chicklets. custom icons and no more share counts!

    i’m curious about how to do the same thing for google+ and linkedin… any thoughts?

  18. User Avatar
    Jonathon Harris
    Permalink to comment#

    Thanks for the great info, Chris. As always, spot on.

    @ilana, I did come across a way to also add a Google+ share link without the Plus icon. A bit late to your post, but in case this helps, here it is in the same format as Chris’s example above.

    // share to Google Plus
    <a rel="nofollow" href="<?php the_permalink(); ?>" title="Share this post on Google+">Share on Google+</a>
  19. User Avatar
    Jonathon Harris
    Permalink to comment#

    On a related note, here is a share link for LinkedIn as well, formatted as the above.

    // share on LinkedIn
    <a rel="nofollow" href="<?php the_permalink(); ?>&title=<?php echo urlencode(get_the_title($id)); ?>&summary=<?php echo get_the_excerpt(); ?>&source=<?php bloginfo('name'); ?>">Share on LinkedIn</a>
  20. User Avatar
    ilana mullin
    Permalink to comment#

    Awesome Jonathan! Thanks for sharing the knowledge!! I had figured out a way for both, but yours are awesome too. Google+ was the sort tough one. For some reason, the box that popped up for me was always in a different language than English, I couldn’t figure out why, the URL was I’ll have to try your solution out!

  21. User Avatar
    Permalink to comment#

    Very useful… many thanks! One little problem, I’m displaying this:
    ” title=”Share this article with your Twitter followers”>Tweet this!
    …when I cut and paste the twitter code. I’m looking closely and comparing with the FB code which seems to be working.

    Please and thanks for any insights.

  22. User Avatar
    Jonathon Harris
    Permalink to comment#

    Hi @Michael, what exactly isn’t working?

    • User Avatar
      Permalink to comment#

      Hi Jonathon,

      I believe this portion:

      ” title=”share this article with your twitter followers”>

      should not be appearing in the browser. I’m cutting and pasting the snippet so I don’t think I’ve altered the mark up in any way. I put the Facebook snippet in and it says “share on Facebook” in the browser. Which seems correct although The link takes me to Facebook but doesn’t paste a link to the page in text window on Facebook. Maybe that is what is supposed to happen. I don’t understand php but it does kind of look like it wants to get the permalink to the page.

      Thanks for your interest and the help.

      I’m using this on a development site at:

    • User Avatar
      Jonathon Harris
      Permalink to comment#

      Hi Michael,
      What are you using for a code editor? On my local dev, the Facebook link carries the link with it, and the Twitter works fine.

      Maybe try copy / pasting the code snippets into Notepad, Notepad++ or any other simple text editor. If you’re using something like Word, or a rich text editor, then you might be having issues with some of the quotation marks and symbols. Could try pasting into Notepad++, select a quotation mark and type the quotation over to see if it switches to a simple quote. Hope that works for you. Nice photos on your site.

  23. User Avatar
    Permalink to comment#

    Thank you for the feedback Jonathon. I will reveal my ignorance and tell you I was just copying and pasting out of the browser window. I’m now putting it into Textmate and saving as a php file before copying it. This did clear up the code showing up in the browser but I still don’t get the link carrying over to FB.
    I have more to experiment and work with now and really appreciate your insight into the problem.
    The photos are indeed nice, but, alas they were taken by my friend who is also named Michael. I’m converting his static site to a WordPress site so he can more easily update his content on his own.

  24. User Avatar
    Permalink to comment#

    Very nice code

  25. User Avatar
    Permalink to comment#

    Very very cool !!

    Now, only need link to share via mail

    any idea?

  26. User Avatar
    Permalink to comment#

    This is awesome info. I’ve been searching for exactly this!!!
    Can someone tell me if I can just replace these for the addthis code I’m actually using?
    It’s because I’m tired for them (addthis) to slow my pageload.

    Thanks to all and,

    Greatest 2013 to you all!!!

  27. User Avatar
    Permalink to comment#

    I’ve implemented most of them… works beautifully except for the g+ which I replaced with this one (retrieved from Google) on this comment date:

    a href={YOUR_URL} title="Share this on Google+">Share on G+

    Thank you all!!!

  28. User Avatar
    Permalink to comment#

    Pinterest? Anyone?

  29. User Avatar
    Permalink to comment#


    Thanks for this snippet! It was excactly what I was looking for!

    If anyone is interested, after reading this I’ve created a small tweet_this($post_id); function for generating Twitter Urls in WordPress with an excerpt of your choice.
    For instance you can use advanced custom fields or the_excerpt() or the_title() as a fallbacks to generate the Tweet.

    The Tweet is shorten to 140 before creating the url.

    You can as well shorten the link if you wish.

    You just have to call the function to generate the URL :

            <a rel="nofollow" href="<?php echo tweet_this($post_id); ?>" title="Share this article with your Twitter followers">Tweet this!</a>

    And your Tweet will look like :
    “Currently reading : Your wonderful chosen (and shorten if needed) excerpt or the_title() as a fallback”

    Check the Gist :

    Any feedback or improvement is welcome!

  30. User Avatar
    ryan wagner

    Awesome work! Thanks for sharing this snippet. I like this because the fact you do not have to use a plugin which I feel slows your load time down.

    Thanks again,
    Ryan Wagner

  31. User Avatar
    Permalink to comment#

    Thank you, this works great! Love how it’s so simple.

    I have a tiny problem with the facebook link tho. I have all the meta properties set up like og:image, but when clicking on the facebook share link for the first time it doesn’t show the featured image. :/

    Is it common for everyone else too?

  32. User Avatar
    Permalink to comment#

    nice code

  33. User Avatar
    Tony Scialdone
    Permalink to comment#

    Here’s my list, in case it helps anyone:"""""""""""

Leave a Comment

Posting Code!

You may write comments in Markdown. This makes code easy to post, as you can write inline code like `<div>this</div>` or multiline blocks of code in triple backtick fences (```) with double new lines before and after.

Code of Conduct

Absolutely anyone is welcome to submit a comment here. But not all comments will be posted. Think of it like writing a letter to the editor. All submitted comments will be read, but not all published. Published comments will be on-topic, helpful, and further the discussion or debate.

Want to tell us something privately?

Feel free to use our contact form. That's a great place to let us know about typos or anything off-topic.