Add Social Share button in WordPress without Plugins

Social share button in WordPress without Plugins

Social Share button is used to promote and share the content of website. Add such social icons and its link in wordpress is great things for customization. Whenever a user visit to your site and like your website post or content then they can share that content on social media using share button with their social account login. It is a great way to promote your article by displaying social share link for each article. There are many plugins for social share widget in WordPress.
Why we need custom social share buttons?
Custom social share buttons are used because plugin are not customized as per user requirement. Here in this article I am going to tell you how you can add manually social share link for each article in wordpress without plugins. Most social share plugins are optimized as per user need and that’s make it require to implement manual share buttons for your post.
It does not require to load any script for manual social share button . Let us see how to add social share button .

Social Share - PHPCluster
Social Share – PHPCluster

It’s pretty and easy to add these social buttons in to your Worpress theme.
Add the php code snippet to your while loop (or single.php, or wherever you need the social share buttons)
For Facebook

<a href="http://www.facebook.com/sharer.php?u=<?php the_permalink();?>&amp;t=<?php the_title(); ?>" title="Share on Facebook."><i class="fa fa-facebook"></i></a>

For Twitter

<a href="http://twitter.com/home/?status=<?php the_title(); ?> - <?php the_permalink(); ?>" title="Tweet this!"><i class="fa fa-twitter"></i></a>

For Pinterest

<a href="http://pinterest.com/pin/create/button/?url=<?php the_permalink(); ?>&media=<?php $url = wp_get_attachment_url( get_post_thumbnail_id($post->ID) ); echo $url; ?>"><i class="fa fa-pinterest"></i></a>

For Google Plus

<a href="https://plus.google.com/share?url=<?php the_permalink(); ?>" onclick="javascript:window.open(this.href,'','menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=600,width=600');return false;"><i class="fa fa-google"></i></a>

For Linkedin

<a class="linkedin" href="http://www.linkedin.com/shareArticle?mini=true&amp;title=<?php the_title(); ?>&amp;url=<?php the_permalink(); ?>" title="Share on LinkedIn" rel="external nofollow" rel="nofollow" target="_blank"><i class="fa fa-linkedin"></i></a>

Here I have not added text within link for social share . I have added here fa fa icon and it need to add fontawesome.min.css for display icon. If you are not able to do so just replace fa fa-facebook with share on facebook text like this and do so on. That’s it.