• Resolved Sukhvinder Sidhu

    (@sukhv)


    I am using a table of contents for my blog posts with a clickable list of H2 headings. If a reader uses a TOC link to reach a section, the related anchor tag gets added at the end of the post URL in browser.

    The AddToAny share buttons use the image and title from the Open Graph but fetch the browser URL including the section heading anchor tag. I found that the Open Graph of the Rank Math plugin does not have any space to write the post URL.

    What can I do to ensure that the share buttons use only the main URL of the post from whatever section the reader may have reached using a TOC link? Please guide.

    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)

    You can strip the # value by modifying the shared URL like so:

    a2a_config.callbacks.push({
    share: function(data) {
    // Remove the hash from all shared URLs.
    data.url = data.url.split('#')[0];
    return data;
    }
    });

    Just add the above code to your Additional JavaScript box in Settings > AddToAny.

    Thread Starter Sukhvinder Sidhu

    (@sukhv)

    Yes, this code has done the job.

    Thank you for the great help!

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