Social Share Buttons on WordPress without Plugin
Currently, so many social sharing plugins are available in the WordPress plugin directory, but the use of too many plugins reduces the website speed. Here I will help you to add a simple social sharing without any plugin. Please copy paste this code into your WordPress theme php file (example page.php, single.php, custom page, archive page (within loop code) ) file.
<a href="http://www.facebook.com/sharer.php?u=<?php the_permalink();?>" target="_blank" class="customer share"> <img src="https://cdn.pixabay.com/photo/2017/06/22/06/22/facebook-2429746_960_720.png" width="42" ></a> <a href="https://plus.google.com/share?url=<?php the_permalink();?>" target="_blank" class="customer share"> <img src="https://cdn.pixabay.com/photo/2017/06/22/14/50/google-plus-2431022_960_720.png" width="42"></a> <a href="http://www.linkedin.com/shareArticle?mini=true&url=<?php the_permalink();?>" target="_blank" class="customer share"> <img src="https://cdn.pixabay.com/photo/2017/08/23/22/59/linked-in-2674741_960_720.png" width="42"></a> <a href="http://twitter.com/share?url=<?php the_permalink();?>" target="_blank" class="customer share"> <img src="https://cdn.pixabay.com/photo/2017/06/22/14/23/twitter-2430933_960_720.png" width="42"></a>
Copy Paste this Js Script into your footer.php
<script> // JavaScript Document Creative tweets // Click on top share button on single posts ;(function($){ /** * jQuery function to prevent default anchor event and take the href * and the title to make a share popup * * @param {[object]} e [Mouse event] * @param {[integer]} intWidth [Popup width defalut 500] * @param {[integer]} intHeight [Popup height defalut 400] * @param {[boolean]} blnResize [Is popup resizeabel default true] */ $.fn.customerPopup = function (e, intWidth, intHeight, blnResize) { // Prevent default anchor event e.preventDefault(); // Set values for window intWidth = intWidth || '500'; intHeight = intHeight || '400'; strResize = (blnResize ? 'yes' : 'no'); // Set title and open popup with focus on it var strTitle = ((typeof this.attr('title') !== 'undefined') ? this.attr('title') : 'Social Share'), strParam = 'width=' + intWidth + ',height=' + intHeight + ',resizable=' + strResize, objWindow = window.open(this.attr('href'), strTitle, strParam).focus(); } /* ================================================== */ $(document).ready(function ($) { $('.customer.share').on("click", function(e) { $(this).customerPopup(e); }); }); }(jQuery)); </script>
If you have any doubt please comment it below.