Skip to content

AddtoAny WordPress Plugin Code To Keep It Center and Pinterest New Tab

AddtoAny Plugin Center + Pinterest New Tab WordPress

AddtoAny is a handy WordPress plugin for displaying share buttons to social media. By using the AddtoAny plugin we will be able to easily share content to social networks such as Facebook, Twitter, Pinterest, even to messenger applications such as WhatsApp, Telegram, WeChat and also of course via Email.

By default, however, AddtoAny is placed on the left-aligned and it is less beautiful. Then by default when sharing to the Pinterest site, Pinterest share view is also by displaying random images so it is inaccurate.

Here you can add some code so that the AddtoAny display is in the middle of the content, and the Pinterest share button displays an accurate feature image. For the guide, follow the steps below.

Make AddtoAny Center and Pinterest Show Feature Image with New Tab

1) After you have installed and activated the AddtoAny plugin, go to the WordPress dashboard then Settings > AddtoAny.

2) Add the following JavaScript code to the “Additional JavaScript” section.

Additional JavaScript

a2a_config.thanks = {
    postShare: false,
    ad: false,
};
// Share the page's "og:image" to Pinterest instead of loading Pinterest's image picker.
a2a_config.callbacks.push({
    share: function(data) {
        if ( 'Pinterest' === data.service ) {
            var image = document.querySelector('meta[property="og:image"]');
            if (image) data.media = image.getAttribute('content');
        }
        return data;
    }
});

3) Add the following CSS code to the “Additional CSS” section

Additional CSS

.addtoany_content{text-align:center;}

4) Click the “Save Changes” button and see the result.

That’s a tutorial on how to make AddtoAny share button plugin in the center and Pinterest share button display a feature image.

Leave a Reply

Your email address will not be published. Required fields are marked *