Skip to content

Instantly share code, notes, and snippets.

@alekskravchenko
Created August 24, 2017 08:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alekskravchenko/0158a0554f3f3e72ca1b2653d3c36ec0 to your computer and use it in GitHub Desktop.
Save alekskravchenko/0158a0554f3f3e72ca1b2653d3c36ec0 to your computer and use it in GitHub Desktop.
social share
<div class="social-share">
<span>Share article</span>
<div class="social">
<a class="social-item social-item--facebook" target="_blank" href="https://www.facebook.com/sharer/sharer.php?u=<?php the_permalink(); ?>"></a>
<?php $pin_image = wp_get_attachment_url( get_post_thumbnail_id($post->ID)); ?>
<a class="social-item social-item--pinterest" data-pin-do="skipLink" target="_blank" href="https://pinterest.com/pin/create/button/?url=<?php the_permalink(); ?>&media=<?php echo $pin_image; ?>&description=<?php the_title(); ?>"></a>
<a class="social-item social-item--twitter" target="_blank" href="https://twitter.com/home?status=Check%20out%20this%20article:%20<?php print social_title( get_the_title() ); ?>%20-%20<?php echo urlencode(the_permalink()); ?>"></a>
<a class="social-item social-item--gplus" target="_blank" href="https://plus.google.com/share?url=<?php the_permalink(); ?>"></a>
<a class="social-item social-item--mail" href="mailto:?subject=<?php the_title();?>&amp;body=<?php the_permalink() ?>" title="Send this article to a friend!"></a>
<a class="social-item social-item--stumbleupon" href="https://www.stumbleupon.com/submit?url=<?php the_permalink() ?>" target="_blank"></a>
</div>
</div>
<!-- Add this function to functions.php -->
function social_title( $title ) {
$title = html_entity_decode( $title );
$title = urlencode( $title );
return $title;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment