Skip to content

Instantly share code, notes, and snippets.

@hasanm95
Last active September 1, 2016 12:25
Show Gist options
  • Save hasanm95/335a121d87560c658df1506f429d38b0 to your computer and use it in GitHub Desktop.
Save hasanm95/335a121d87560c658df1506f429d38b0 to your computer and use it in GitHub Desktop.
wordpress post share option
function share_this($content){
if(is_single()){
$content .= '<div class="share_this">';
$title = get_the_title();
$permalink = get_permalink();
$twitter_handler = (get_option('twitter_handler') ? '&amp;via='.esc_attr(get_option('twitter_handler')) : '');
$twitter = 'https://twitter.com/intent/tweet?text='.$title.'&amp;url='.$permalink.$twitter_handler.'';
$facebook = 'https://www.facebook.com/sharer/sharer.php?u='.$permalink;
$google = 'https://plus.google.com/share?url=' . $permalink;
$content .= '<ul>';
$content .= '<li><a href="' . $twitter . '" target="_blank" rel="nofollow"><i class="fa fa-twitter" aria-hidden="true"></i>
Twitter</a></li>';
$content .= '<li><a href="' . $facebook . '" target="_blank" rel="nofollow"><i class="fa fa-facebook" aria-hidden="true"></i>
Facebook</a></li>';
$content .= '<li><a href="' . $google . '" target="_blank" rel="nofollow"><i class="fa fa-google-plus" aria-hidden="true"></i>Google Plus </a></li>';
$content .= '</ul></div>';
return $content;
}else{
return $content;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment