3/14/2018 - 3:37 PM

WordPress share

A custom sharefunction if you don't want to use addThis or something similar.

function awave_custom_social_sharing_buttons() {
	global $post;

	// Get current page URL
	$url = urlencode(get_permalink());

	// Get current page title
	$title = str_replace( ' ', '%20', get_the_title());

	// Construct sharing URL without using any script
	$twitterURL = ''.$title.'&amp;url='.$url.'&amp;via=WhistleB';
	$facebookURL = ''.$url;
	$linkedInURL = ''.$url.'&amp;title='.$url;

	// Add sharing button at the end of page/page content
	echo '<ul class="social-share">';
	echo '<li><span>'.__('Share article:').'</span></li>';
	echo '<li><a class="share-link share-twitter" href="'. $twitterURL .'" target="_blank"><i class="fa fa-twitter" aria-hidden="true"></i></a></li>';
	echo '<li><a class="share-link share-linkedin" href="'.$linkedInURL.'" target="_blank"><i class="fa fa-linkedin" aria-hidden="true"></i></a></li>';
	echo '<li><a class="share-link share-facebook" href="'.$facebookURL.'" target="_blank"><i class="fa fa-facebook" aria-hidden="true"></i></a></li>';
	echo '</ul>';