Created
January 31, 2012 19:08
-
-
Save ramseyp/1712245 to your computer and use it in GitHub Desktop.
Social Media Sharing code for WordPress articles
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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();?>&send=false&layout=button_count&width=200&show_faces=false&action=like&colorscheme=light&font&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