Skip to content

Instantly share code, notes, and snippets.

@ramseyp
Created January 31, 2012 19:08
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ramseyp/1712245 to your computer and use it in GitHub Desktop.
Save ramseyp/1712245 to your computer and use it in GitHub Desktop.
Social Media Sharing code for WordPress articles
<?php
/* Add a social media share box to your WordPress site.
If you want the email sharing, you'll need to install WP-Email: http://wordpress.org/extend/plugins/wp-email/
Insert <?php s25_sharing_caring(); ?> to your template where you want the box to appear. Must be used inside the Loop.
Facebook Like Button code can be built here: http://developers.facebook.com/docs/reference/plugins/like/
Tweet Button code: https://dev.twitter.com/docs/tweet-button
LinkedIn Share Button: http://developer.linkedin.com/plugins/share-plugin-generator
Google Plus 1: http://www.google.com/webmasters/+1/button/
*/
function s25_sharing_caring() {
$post_type = get_post_type();
$include = array('post');
if(is_single() && in_array($post_type, $include)):
?><ul class="shareme">
<?php if(function_exists('wp_email')) { ?><li class="email"> <?php email_link(); ?></li><?php } ?>
<li><a href="http://twitter.com/share?url=<?php the_permalink();?>" class="twitter-share-button" data-count="horizontal">Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script></li>
<li><script type="text/javascript" src="http://platform.linkedin.com/in.js"></script><script type="in/share" data-counter="horizontal"></script></li>
<li><iframe src="http://www.facebook.com/plugins/like.php?href=<?php the_permalink();?>&amp;send=false&amp;layout=button_count&amp;width=200&amp;show_faces=false&amp;action=like&amp;colorscheme=light&amp;font&amp;height=25" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:200px;height:25px;" allowTransparency="true"></iframe></li>
</ul><!-- end .share --><?php
endif;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment