Support » Plugin: AddToAny Share Buttons » Remove separator and site name from Twitter message

  • Resolved myproverbialthoughts

    (@myproverbialthoughts)


    First off, as a non-developer I can’t stress enough how much I appreciate the customization resources you’ve made available! I am getting stuck in a couple of areas, however, and am hoping someone can help.

    For the Twitter message, right now I’m using a2a_config.templates.twitter = “${title} ${link} via @mysite“; which outputs: Page Title | My Site http://www.mysite.com via @mysite

    But I’d like the Twitter Message to simply be: Page Title http://www.mysite.com via @mysite without the separator and site name.

    How do I solve for this?

    Thanks in advance!

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author micropat

    (@micropat)

    You can modify the shared title using AddToAny Events. For example, add the following code to your “Additional JavaScript” box in AddToAny Settings:

    a2a_config.callbacks.push({
        share: function(data) {
            if (data.service === 'Twitter') {
                return {
                    title: data.title.replace(' | My Site', '')
                };
            }
        }
    });

    In the example, all occurrences of | My Site will be removed from the title when shared to Twitter.

    If you want to make sure that ” | My Site” is only ever replaced when at the end of the title, the “regular expression” syntax is a little trickier: you would use / \| My Site$/ instead of ' | My Site' in the example above.

    myproverbialthoughts

    (@myproverbialthoughts)

    Thanks! I really appreciate the quick response.

    Can I use something similar for the text that gets pushed to Buffer?

    Plugin Author micropat

    (@micropat)

    Yep, for Buffer too. Just change:

    if (data.service === 'Twitter') {

    to:

    if (data.service === 'Twitter' || data.service === 'Buffer') {

    myproverbialthoughts

    (@myproverbialthoughts)

    That worked great. Thanks again!

Viewing 4 replies - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.