share wordpress post description on whatsapp without plugin code example
Example 1: share wordpress post on whatsapp without plugin
<?php $url = urlencode(get_the_permalink()); $title = htmlspecialchars(urlencode(html_entity_decode(get_the_title(), ENT_COMPAT, 'UTF-8')), ENT_COMPAT, 'UTF-8'); ?>
<div class='social-share'>
<a class='fb' target="_blank" href="http://www.facebook.com/sharer.php?u=<?php echo $url;?>">Facebook</a>
<a class='tw' target="_blank" href="https://twitter.com/intent/tweet?url=<?php echo $url;?>&text=<?php echo $title; ?>">Twitter</a>
<a class='pi' href="javascript:void((function()%7Bvar%20e=document.createElement('script');e.setAttribute('type','text/javascript');e.setAttribute('charset','UTF-8');e.setAttribute('src','//assets.pinterest.com/js/pinmarklet.js?r='+Math.random()*99999999);document.body.appendChild(e)%7D)());">Pinterest</a>
<a class='go' target="_blank" href="https://plus.google.com/share?url=<?php echo $url;?>">Google+</a>
<a class='li' target="_blank" href="http://www.linkedin.com/shareArticle?mini=true&url=<?php echo $url;?>">Linkedin </a>
<a class='wh' href="whatsapp://send?text=<?php echo ($title ." ". $url);?>">WhatsApp</a>
<a class='ma' target="_blank" href="mailto:?subject=<?php echo $title;?>&body=%20<?php echo $url;?>">EMAIL</a>
</div>
Example 2: share wordpress post on whatsapp without plugin
add_filter('the_content', 'br_content_with_social_buttons');
function br_content_with_social_buttons($content){
$url = urlencode(get_permalink());
$title = str_replace(' ', '%20', get_the_title());
$blog_title = get_bloginfo('name');
$content .='
<div id="social-share">
<strong><span>Sharing is caring</span></strong> <i class="fa fa-share-alt"></i>
<a href="https://www.facebook.com/sharer.php?u='.$url.'" target="_blank" class="facebook"><i class="fa fa-facebook"></i> <span>Share</span></a>
<a href="https://plus.google.com/share?url='.$url.'" target="_blank" class="gplus"><i class="fa fa-google-plus"></i> <span>+1</span></a>
<a href="https://twitter.com/intent/tweet?text='.$title.'&url='.$url.'&via=YOUR_TWITTER_HANDLE_HERE" target="_blank" class="twitter"><i class="fa fa-twitter"></i> <span>Tweet</span></a>
<a href="http://www.linkedin.com/shareArticle?mini=true&url='.$title.'" target="_blank" class="linkedin"><i class="fa fa-linkedin"></i> <span>Share</span></a>
<a href="whatsapp://send?text='.$title.' '.$url.'" target="_blank" class="whatsapp"><i class="fa fa-whatsapp"></i> <span>Share</span></a>
</div>';
return $content;
}