Op-edAdding Facebook, Twitter, Reddit and LinkedIn Social Share links to Wordpress without...

Adding Facebook, Twitter, Reddit and LinkedIn Social Share links to WordPress without any Plugin

NOTE: This post maybe outdated. Require export review!

WordPress is one of the best and widely used CMS that offers easy content management which does not mean that you will get everything you want as it lack basic features which include social sharing well, you can have it as well by installing plugins. But, wait a minute do you really need a plugin for it?

Adding Plugins is going to burden your website or the blog and if you are a blogger or a business owner then you must be aware that website speed is the key to success in terms of blogging as well as running a business smoothly. Even you need to keep the plugins upto date and don’t forget most of plugins comes with vulnerable codes that opens the gate for the hackers. Even what I have personally found that these plugins uses their own JavaScript (.js) and .css files which again causes problem either in loading the website or eroding your website’s performance in terms of speed.

Well, today I’ll share the trick that how you can add social share buttons like Facebook, Twitter (with hashtag), linkedIn and reddit.

Thins you will need
1. Social Icon of Facebook, Twitter, Google Plus, Reddit and LinkedIn
2. Sample PHP Script

You can download social icons from here (not available)

You need to add following HTML cum PHP script to your content-single.php (it may vary in different themes). You need to dig a bit.

Also Read: How To Enable Contributors Manage Media In WordPress?

Adding Facebook Share Button / link

<a href="https://www.facebook.com/dialog/share?app_id=YOUR_FB-APP_ID&display=popup&
href=<?php echo get_permalink();?>&redirect_uri=<?php echo get_permalink();?>" 
target="_blank" rel="nofollow"> <img src="FULL_PATH_OF_FACEBOOK_ICON" 
img="Facebook" width="32px" height="32px"></a>

Adding Twitter Share Button with Hashtag

<a href="https://twitter.com/share/?text=<?php 
echo the_title()."&url=".wp_get_shortlink();?>&hashtags=<?php 
echo str_replace(' ','',strip_tags(get_the_tag_list('',', ','')));?>" 
target="_blank" rel="nofollow"><img src="FULL_PATH_OF_TWITTER_ICON" 
width="32px" alt="Twitter" height="32px"></a>

Adding Reddit Share Button

<a href="http://www.reddit.com/submit?url=<?php 
echo get_permalink();?>&title=<?php echo single_post_title();?>" 
target="_blank" rel="nofollow"><img 
src="FULL_PATH_OF_REDDIT_ICON" alt="Reddit" width="32px" height="32px"></a>

Adding Google Plus Share Button

<a href="https://plus.google.com/share?url=<?php 
echo get_permalink();?>" rel="nofollow" 
target="_blank"><img src="FULL_PATH_OF_Google-Plus_ICON" 
alt="Google Plus" width="32px" height="32px"></a>

Adding LinkedIn Share Button

<a href="https://www.linkedin.com/cws/share?url=<?php 
echo get_permalink();?>" target="_blank" 
rel="nofollow"><img src="FULL_PATH_OF_LinkedIn_ICON" 
alt="Linkedin" width="32px" height="32px"></a>

Isrg Team
Isrg Team
Isrg Team is a member of Digital Pradesh News Networks, a collective of journalists, reporters, writers, editors, lawyers, advocates, professors, and scholars affiliated with the Digital Pradesh News Network.

Latest Updates