AddToSite

← All platforms

Guide

Share buttons for WordPress

Add the buttons under every post without touching a theme file twice.

Where they end up: Under the content of every post, on self-hosted WordPress.

  1. 01

    Load the script once, site-wide

    Appearance → Theme File Editor, or better, a child theme. Add this to functions.php so the script loads on every page rather than being pasted into each post.

    php
    add_action('wp_enqueue_scripts', function () {
        wp_enqueue_script(
            'addtosite',
            '//static.addtosite.com/widget.js',
            array(),
            null,
            true
        );
    });
  2. 02

    Append the buttons to every post

    Still in functions.php. Filtering the_content puts the buttons under the post body wherever your theme renders it, so a theme update cannot lose them.

    php
    add_filter('the_content', function ($content) {
        if (!is_singular('post') || !in_the_loop() || !is_main_query()) {
            return $content;
        }
    
        $kit = '<div class="ats_kit ats_kit_size_32"'
             . ' data-url="' . esc_url(get_permalink()) . '"'
             . ' data-title="' . esc_attr(get_the_title()) . '">'
             . '<a class="ats_button_facebook"></a>'
             . '<a class="ats_button_x"></a>'
             . '<a class="ats_button_linkedin"></a>'
             . '<a class="ats_button_email"></a>'
             . '<a class="ats_dd"></a>'
             . '</div>';
    
        return $content . $kit;
    });
  3. 03

    Or drop it into one post by hand

    In the block editor, add a Custom HTML block where you want the buttons and paste the snippet the configurator gives you. Good for trying it out before committing to the filter.

Want a different set of services?

The snippets above use a sensible default. The configurator builds the exact markup for whichever services you want, in whichever order, at whichever size — paste that in place of the kit shown here.