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

    (@micropat)

    Usually a theme or some other plugin is handling the meta tags on your pages. Most major social networks look up a page’s meta tags for title, description, and a preview image.

    Some services let you add or specify the default text, and AddToAny Templates allow you to configure those.

    Thread Starter bcvcbhqyxcgakhh

    (@bcvcbhqyxcgakhh)

    I have created demo example using PHP and JavaScript. How to connect those scripts and WordPress?

    WordPress already gives you the post data in PHP. How to set Inside the post loop, and get the current post URL with get_permalink() and pass it into our JavaScript? WordPress handles which post is being viewed.

    <?php

    add_shortcode( 'addtoany', 'A2A_SHARE_SAVE_shortcode' );
    function A2A_SHARE_SAVE_shortcode( $attributes ) {
    $attributes = shortcode_atts( array(
    'url' => '',
    'title' => '',
    'media' => '',
    'buttons' => '',
    ), $attributes, 'addtoany' );

    $linkname = $attributes['title'];
    $linkurl = $attributes['url'];
    $linkmedia = $attributes['media'];
    $buttons = ! empty( $attributes['buttons'] ) ? explode( ',', $attributes['buttons'] ) : array();

    $output_later = true;

    return '<div class="addtoany_shortcode">'
    . ADDTOANY_SHARE_SAVE_KIT( compact( 'linkname', 'linkurl', 'linkmedia', 'output_later', 'buttons' ) )
    . '</div>';
    }
    ?>
    <script type="text/javascript">
    a2a_config.templates.email = {
    subject: "Check this out: ${title}",
    body: "Click the link:\n${link}",
    };

    a2a_config.templates.facebook = {
    hashtag: "#AddToAny",
    };

    a2a_config.templates.sms = {
    body: "Check this out: ${title} ${link}",
    };

    a2a_config.templates.whatsapp = {
    phone: "15551234567",
    text: "I'm interested in ${title} posted here: ${link}",
    };

    a2a_config.templates.x = {
    text: "Check this out: ${title} ${link}",
    };
    </script>
Viewing 2 replies - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.