Nowadays, social media sharing is required for any web related projects. Some advantages of the social media sharing are :
  • Reduced in marketing costs.
  • Increased in sales.
  • Increased traffic to your website.
  • Improved ranking on search engines.
There are so many free and easy-to-implement services out there. But all those social sharing plugins are used lot of JavaScript which is increase page load time. So, if you want to customize social sharing button as per your project theme and load page faster, then it will be a good idea to use social share buttons with custom links.

       For Googleplus :
<a href="https://plus.google.com/share?url=<?php echo $_SERVER[HTTP_HOST] . $_SERVER[REQUEST_URI]; ?>" target="_blank" class="share-btn google-plus">

For Facebook:
<a href="https://www.facebook.com/sharer.php?u=<?php echo $_SERVER[HTTP_HOST] . $_SERVER[REQUEST_URI];  ?> " target="_blank" class="share-btn facebook">

For LinkedIn:
<a href="http://www.linkedin.com/shareArticle?url=<?php echo $_SERVER[HTTP_HOST] . $_SERVER[REQUEST_URI]; ?>" target="_blank" class="share-btn linkedin">


<?php echo $_SERVER[HTTP_HOST] . $_SERVER[REQUEST_URI]; ?>
The Above PHP Code will take the current URL of the website or your project. Now we have to create an icon for this using HTML and CSS. There is a simple way to design these icons using FontAwesome, 
just we have to include font awesome CDN path in the header, I.e,


<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">


<div class="socialShare">
<a href="https://plus.google.com/share?url=<?php echo $_SERVER[HTTP_HOST] . $_SERVER[REQUEST_URI]; ?>" target="_blank" class="share-btn google-plus">
           <i class="fa fa-google-plus"></i></a>

<a href="https://www.facebook.com/sharer.php?u=<?php echo $_SERVER[HTTP_HOST] . $_SERVER[REQUEST_URI];  ?> " target="_blank" class="share-btn facebook">
 <i class="fa fa-facebook"></i></a> 

<a href="http://www.linkedin.com/shareArticle?url=<?php echo $_SERVER[HTTP_HOST] . $_SERVER[REQUEST_URI]; ?>" target="_blank" class="share-btn linkedin">
<i class="fa fa-linkedin" style="margin-left:5px;"></i></a> 
</div>



Post a Comment

Previous Post Next Post