Fully Valid, SEO-Friendly Social Media Links for WordPress

[ Social Media ] With the explosion of social media, networking, and bookmarking services, there are a zillion ways to add “Share This Post” functionality to your WordPress-powered sites. In addition to the myriad services and plugins, we can also add these links directly, using nothing more than a little markup and a few choice PHP snippets. Such individual links provide full control over the selection, layout, and styling of each link without requiring the installation of yet another WordPress plugin.

This article shares SEO-friendly code snippets for ten of the most popular social media sites using completely valid XHMTL-Strict markup. All of the following code snippets feature:

  • nofollow attributes to conserve pagerank
  • descriptive title attributes for every link
  • encoded ampersands via & characters to keep ‘em valid
  • WordPress template tags for dynamic permalink and title generation
  • PHP’s urlencode() function to encode titles for valid code

Everything here is 100% copy-&-paste, plug-n-play, and ready to go! No editing required! Simply add this code to the desired location in your markup and enjoy! :)


It seems like all of my non-geek friends and relatives have managed to find me on Facebook. Here’s a way to let them share your posts with each other:

<a rel="nofollow" href="http://www.facebook.com/sharer.php?u=<?php the_permalink();?>&amp;t=<?php echo urlencode(get_the_title($id)); ?>" title="Share this post on Facebook">Share on Facebook</a>


Here is a “quick-and-dirty” way to enable visitors to easily and quickly tweet your posts with a single click:

<a rel="nofollow" href="http://twitter.com/home?status=<?php echo urlencode("Currently reading: "); ?><?php the_permalink(); ?>" title="Share this article with your Twitter followers">Tweet this!</a>


And of course, we can’t forget Reddit, a social linking site that is very popular among certain circles. Here’s how to get in on the action:

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


AddThis.com is a popular service that enables users to easily add your posts to a zillion different social sites. Once you have an account, change “USERNAME” in the code below and use the link as a fallback for your readers to share your site with the obscure site of their choice:

<a rel="nofollow" href="http://www.addthis.com/bookmark.php?pub=USERNAME&amp;url=<?php echo get_permalink(); ?>&amp;title=<?php echo urlencode(get_the_title($id)); ?>" title="Bookmark this article at your favorite social media site">Share this post at your favorite social media site</a>

Got More?

While we’re on the subject, what are your favorite social media sites? Did I cover all the most popular sites, or are there others that should be added to this post? Either way, by extrapolating the techniques used in this article, you can add a custom “Share This” link for just about any of your favorite social media services.

{ Hard to believe it’s almost December.. }

More Information