Beginner's Guide for WordPress - Start your WordPress Blog in minutes.
Choosing the Best
WordPress Hosting
How to Easily
Install WordPress
WordPress Plugins
View all Guides

Social Media Cheat Sheet for WordPress

Last updated on by
Special WordPress Hosting offer for WPBeginner Readers
Social Media Cheat Sheet for WordPress

One of the ways to get more exposure to your blog is by word of mouth advertising. Social Media makes that easy for us. You can encourage your audience to vote for your article or share your article in social media sites by incorporating Social Media Interactivity in WordPress. In this article we will show you how you can add social media icons for each post in WordPress.

This is a cheat sheet for WordPress and we will mention some of the top sharing icons used by bloggers. But before you just copy and paste each code, you will need to understand how it works.

Code for Page/Post Title

<?php the_title(); ?>

Your Page URL – SEO Friendly URL

<?php the_permalink() ?>

Your Short Branded URL (Tutorial)

<?php echo get_bloginfo('url')."/?p=".$post->ID; ?>

Your Current Theme Directory

<?php bloginfo('template_directory'); ?>

We are using the above codes in each social media embedding that we mentioned below. Since most people display this as mini icons at the bottom of the post, you would need to add those icons in your theme images gallery which is located at


Make sure to change the image format (.jpg, .gif, .png or other) and styling to fit your template needs.

The codes below will need to be pasted in single.php and/or page.php.

Add My Posts to Digg

<a href=";url=<?php the_permalink() ?>" rel="nofollow"><img src="<?php bloginfo('template_directory'); ?>/images/digg.png" alt="Add this Article to Digg" /></a>

Add My Posts to Stumbleupon

<a href="<?php the_permalink() ?>&amp;title=<?php the_title(); ?>" rel="nofollow"><img src="<?php bloginfo('template_directory'); ?>/images/stumble.png" alt="Add this Article to Stumbleupon" /></a>

Add My Posts to Delicious

<a href="<?php the_permalink() ?>&amp;title=<?php the_title(); ?>" rel="nofollow"><img src="<?php bloginfo('template_directory'); ?>/images/delicious.png" alt="Add this Article to" /></a>

Add My Posts to Reddit

<a href="<?php the_permalink() ?>&amp;title=<?php the_title(); ?>" rel="nofollow"><img src="<?php bloginfo('template_directory'); ?>/images/reddit.png" alt="Add this Article to Reddit" class="left" /></a>

Add My Posts to Newsvine

<a href=";save?u=<?php the_permalink() ?>" rel="nofollow"><img src="<?php bloginfo('template_directory'); ?>/images/newsvine.png" alt="Add this Article to Newsvine" class="left" /></a>

Share this Article on Facebook

<a href="<?php the_permalink(); ?>&t=<?php the_title(); ?>" target="blank"><img src="<?php bloginfo('template_directory'); ?>/images/facebook.png" alt="Share this article on Facebook" /></a>

Share this Article on Twitter

<a href=" <?php the_title(); ?> – <?php echo get_bloginfo('url')."/?p=".$post->ID; ?>" title="Click to send this page to Twitter!" target="_blank"><img src="<?php bloginfo('template_directory'); ?>/images/twitter.png" alt="Share this Article on Twitter" /></a>

We are using your short branded URL in this code.

You can also use the tweetmeme retweet button like we are using by following this tutorial.

Social Media Interactivity can also be incorporated in your posts by the use of famous plugins like Sharethis, Sociable, and Add to Any.

We feel that above codes are the most popular ones used, but if you think that there are other social media profile codes that should be included and you know the codes, feel free to let us know via comment, email, or twitter and we will add it here.

Editorial Staff at WPBeginner is a team of WordPress experts led by Syed Balkhi. Page maintained by Syed Balkhi.

WPBeginner's Video Icon
Our HD-Quality tutorial videos for WordPress Beginners will teach you how to use WordPress to create and manage your own website in about an hour. Get started now »


  1. Anmol Makkar says:

    How can I manually add this in Genesis ? There’s no single.php in child themes.

  2. Whitney says:

    Where do these codes go in the single.php and page.php files? I am looking to add buttons to the bottom of every post and am having a hard time finding a good step-by-step guide. Thanks for your help!

    • Editorial Staff says:

      It will go in your single.php after the_content() part in your code.

      • Whitney says:

        Thanks so much, it is working perfectly!! One more question… I would like to add “tweet” “like” and “pin” buttons with counters (similar to the ones at the bottom of this post), but I would like to have the buttons I designed rather than the standard twitter, etc. buttons. Is there an easy way to do this, or a how to on here? Again, thanks for the help! It’s amazing this was posted over 3 years ago and is still relevant!

  3. Carla says:

    Well, three years later and this post is still being read. :)

    So if you don’t mind, I have a question:

    Does this code work if placed at the bottom of posts on my homepage (instead of single.php)? I’m not a fan of using plugins for social media, but I know there’s been some problems before with hand-coding and not being able to grab the permalink when the code is on the homepage.

    Thank you!

  4. Olospo says:

    Really useful article thanks.

  5. Scottify says:

    Really good article, was looking at how to do this over the weekend but this was exactly what I needed. Cheers

  6. Pritush says:

    nice tutorial, i am using wpsexybookmarks for this kind of purpose, i will be soon adding tweet button

  7. Dario Gutierrez says:

    This a great tip very useful.

  8. Igor Kheifets-IgorHelpsYouSucceed says:

    WOW! Finally! I’ve been looking for
    this for over couple of month now.

    All those sharing plugins suck, now I can
    finally do my own thing!



  9. Veronica says:

    Thanks for sharing the above information.

    However, I am still a little confused. Had gone thru the SEO friendly URL & understood that section. However for the above Code for Page/Post Title, Your Page URL, Your ShortBranded URL & Your Current Theme Directory, where are we supposed to paste the code?

    How & Where do we find the single.php and/or page.php?

    • Editorial Staff says:

      You are not suppose to paste those code anywhere. That is just a guide for your reference to see how the codes like Digg, Stumble and others are working. Which php tag refers to what, so you can use it for other services that you may want to include.

  10. Carma Spence-Pothitt says:

    Great post. I’m sharing it on Twitter and have saved a PDF copy on HD to refer to later. I like having this option because sometimes my social media plugins don’t play well with other plugins and I don’t want to loose this functionality.

  11. Craig Wann says:

    Great! Thanks!

  12. websudasa says:

    It’s fine to have these codes but why we should use these codes if we already have one button “Share This” & many more.


    • Editorial Staff says:

      That is because not everyone like Share This button. Some people do not want to install a plugin and have some bugs in it and get hacked. Plugins also slows down your site a little bit. Sometimes when designing a custom site, plugins might have aligning issues, which will require you to edit the plugin itself for displaying icons, and each time plugin upgrades, if you edited a core file, you will need to edit that and many other reasons….

    • Nitin Reddy Katkam says:

      Often, you may not get the output in the right style for your theme or you might want to create a custom interface that isn’t provided by any of the existing link sharing plugins for WordPress.

      You could also put this functionality directly into your theme and provide theme customization options instead of getting blog owners to download and install a plugin.

  13. Michael Clayton says:

    Thanks for putting together this little resource. Really helpful.

  14. joyoge bookmark says:

    wow this is very helpful post, thank you so much..

Add a Comment

We're glad you have chosen to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.