Support » Plugin: AddToAny Share Buttons » share url with post id

  • Resolved kamhang

    (@kamhang)


    Hi,

    My site use Chinese url, when user use addtoany, it shares the url with two-digit hexadecimal numbers, not the correct Chinese url.

    Can we custom addtoany to fetch post id as url when user share the url, such as https://www.mysite.com/?p=123

    Thank you

    The page I need help with: [log in to see the link]

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

    (@micropat)

    Hello,

    You can have AddToAny use the shortlink URL by adding the following code to your Additional JavaScript box in AddToAny Settings:

    // Use WordPress shortlink
    a2a_config.callbacks.push({
        share: function(data) {
            if ( location.href === data.url ) {
                var shortlink = document.querySelector('link[rel="shortlink"]');
                if ( shortlink && shortlink.href ) {
                    data.url = shortlink.href;
                }
            }
    
            return data;
        }
    });
    Thread Starter kamhang

    (@kamhang)

    Hi,

    it works.

    Thank you

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