Social sharing links codes evolve often. And many are very complex, including the design and more.
Here’s one that’s up to date as 2023 1st quarter, and that’s simple and easy to use.
Add this script first:
<script>
$(document).ready(function () {
let title = document.title;
let url = window.location.href;
$('[data-share-facebook').attr('href', 'https://www.facebook.com/sharer/sharer.php?u=' + url + '%2F&title=' + title + '%3F');
$('[data-share-facebook').attr('target', '_blank');
$('[data-share-twitter').attr('href', 'https://twitter.com/share?url=' + url + '%2F&title=' + title + '&summary=');
$('[data-share-twitter').attr('target', '_blank');
$('[data-share-linkedin').attr('href', 'https://www.linkedin.com/shareArticle?mini=true&url=' + url + '%2F&title=' + title + '&summary=');
$('[data-share-linkedin').attr('target', '_blank');
$('[data-share-whatsapp').attr('href', 'https://wa.me/?text=' + url);
$('[data-share-whatsapp').attr('target', '_blank');
});
</script>
Then add buttons or blocks of links to your page, and style them to your liking. We will add a custom attribute to these elements, which will allow us to share them on social media.
Name : data-share-twitter
value : true
Name : data-share-linkedin
value : true
Name : data-share-facebook
value : true
Name : data-share-whatsapp
value : true