manually defining the data-link attribute for individual posts
-
On our site, we need to change the default slug for a type of post (used for our recipes (see here)), which will change the URLs of many posts that we’ve had shared on social media. We want to maintain the proper share count for these posts after the url change. I see a solution to this on shareaholic’s support site (see here and here), by redefining the data-link attribute, but I can’t find a way to do this when using this plugin. Is there a way to change the data-link manually, or any other way to maintain proper share counts after changing a URL? If not, can this be added to the next update, so that in the editor there is an option to do this along with the other individual override options that are provided?
-
Yes you can!
You can use custom fields to specify the custom link in a Custom Field and setup the Shareaholic shortcode in your template to use that. For example:
echo do_shortcode('[shareaholic app="share_buttons" id="<insert shareaholic app ID here>" title="About Me" link="'. get_post_meta(get_the_ID(), "shareaholic-custom-data-link", true). '"]');Helpful links:
- Shareaholic Shortcode: https://wordpress.org/plugins/shareaholic/installation/
- Shareaholic data-links: http://support.shareaholic.com/hc/en-us/articles/200471586-Customize-Share-Titles-Links-Images
- Custom Fields: https://codex.wordpress.org/Custom_Fields
Let us know how it goes!
Thanks for the reply. I’ve read through this and the links you provided and played around for a half hour, but honestly, this is just way over my head. It’s like trying to read a different language. Is there any chance someone could walk me through it step by step? I’m not a programmer and don’t know php, so I don’t feel I can do much with this info. 🙁
@jon I’d definitely peg this one as “Advanced” and is going to be hard to implement if you don’t know basic PHP as it will require edits to your theme template.
Were you able to setup a custom field? – https://codex.wordpress.org/Custom_Fields
I’m online in our guest chat room for the next 10-15 minutes if you’d like to chat 1:1 live. https://www.hipchat.com/gnzzy5DQC
Thanks again. I was offline when you replied. I’ll try to spend some time learning how to do this and maybe find someone to walk me through it. Will let you know if I figure it out.
Also thinking, this would make for a great blog post on the shareaholic site. A step-by-step would really help people out. It must be a fairly common issue, and I assume most people just move on, not knowing it’s possible to change the URL and maintain the share count, or, like me, not knowing how to do it.
Anyway, thanks for helping out. 🙂
The topic ‘manually defining the data-link attribute for individual posts’ is closed to new replies.