For anyone looking to create custom social sharing buttons, this is what I set up for a project recently and is working well. Posted here originally but making a new topic where this won’t be buried so far down in comments.
Facebook:
Give your Facebook button an ID of facebook-button:
Add the follwing code snippet to the body code of the page in question:
This is great! Thank you so much for putting this together! I really appreciate it!
Is there a workaround to have these twice on one page? I would love these to be at the top of a blog and at the bottom. But when I add the ones to the bottom, they don’t work I’m guessing because there can only be on ID on one page?
Hi again @jasondark
If I would like to not share the current page, but write a text with another link. How would the code look like? I’m specifically looking for the Twitter share button.
I’m guessing there is something in here: ‘href’, https://twitter.com/share?url=${window.location.href}
But I cant figure it out. Hope you can help and that its not too much trouble
Yes, you would have to use something other than IDs for selectors. Maybe use a class name or data attribute. Then you would need to alter the script to reference all the buttons and apply the sharing logic to each.
This is an example for Twitter share buttons using a class name selector instead of ID. The class name is twt-btn:
It’s a bit unrelated question. I want to add the comment section in my blog post. Do you might know how to do it? The share buttons work well by the way.
@jasondark is there a way to change the description & add an image to the post when using this script? It works perfectly so far but it looks kind of ugly and the description is a random piece of text on the page.