|
<style> |
|
div.social-share {position:absolute; bottom:0; right:0; text-align:center} |
|
div.social-share h5 {font-size:0.875em; color:#333; text-transform:uppercase; margin:0} |
|
div.social-share ul {padding:0; margin:0; list-style:none; font-size:2em} |
|
div.social-share ul li {display:inline-block; margin-right:0.375em} |
|
div.social-share ul li:last-child {margin:0} |
|
div.social-share ul li a span {display:none} |
|
div.social-share ul li a {text-decoration:none} |
|
/* Change links to official colours */ |
|
div.social-share ul li.facebook a {color:#3b5998} |
|
div.social-share ul li.twitter a {color:#1da1f2} |
|
div.social-share ul li.pinterest a {color:#bd081c} |
|
div.social-share ul li.email-share a {color:#333} |
|
</style> |
|
<?php |
|
// Social share buttons |
|
$title = get_the_title(); |
|
$title_encoded = urlencode( html_entity_decode( $title, ENT_COMPAT, 'UTF-8' ) ); |
|
$permalink = get_permalink(); |
|
$sitename = get_bloginfo('name'); |
|
$siteurl = site_url(); |
|
$imageid = get_post_thumbnail_id(); |
|
$media = wp_get_attachment_url( $imageid ); |
|
echo '<div class="social-share">'; |
|
echo '<h5>Share this post</h5>'; |
|
echo '<ul>'; |
|
// Facebook |
|
echo '<li class="facebook"><a target="_blank" href="http://www.facebook.com/sharer.php?u=' . $permalink . '&t=' . $title . '" title="Share this on Facebook!"><i class="fa fa-facebook-square"></i> <span>Facebook</span></a></li>'; |
|
// Twitter |
|
echo '<li class="twitter"><a target="_blank" href="http://twitter.com/home?status=' . $title_encoded . ': ' . $permalink . '" title="Share this on Twitter!"><i class="fa fa-twitter-square"></i> <span>Twitter</span></a></li>'; |
|
// Pinterest |
|
echo '<li class="pinterest"><a target="_blank" href="http://pinterest.com/pin/create/button/?url=' . $permalink; |
|
if ( $thumbnail ) { |
|
echo '&media=' . $media; |
|
} |
|
echo '&description=' . $title . ' on ' . $sitename . ' ' . $siteurl . '" class="pin-it-button" count-layout="horizontal" title="Share on Pinterest!"><i class="fa fa-pinterest-square"></i> <span>Pinterest</span></a></li>'; |
|
// Email |
|
echo '<li class="email-share"><a title="Share by email" href="mailto:?subject=Check out this freebie: ' . $title . '&body=' . $permalink . '"><i class="fa fa-envelope"></i> <span>Share by email</span></a></li>'; |
|
echo '</ul>'; |
|
echo '</div>'; |
|
?> |
Social share links
A fairly straightforward social share gizmo, designed to work in single.php. No JS. Basic CSS is included.
Uses FontAwesome for the icons.