Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author Weston Ruter

    (@westonruter)

    Is it ok to show the share button at the end of the content? If so, then you could just do this:

    add_filter( 'the_content', function( $content ) {
        if ( function_exists( 'is_amp_endpoint' ) && is_amp_endpoint() ) {
            $content .= "\n\n";
            $content .= "<amp-addthis>...</amp-addthis>"; // Add the desired attributes.
        }
        return $content;
    } );

    In this approach, you won’t have to modify any templates. You just have to include this in your theme’s functions.php.

    • This reply was modified 5 years, 8 months ago by Weston Ruter.
    • This reply was modified 5 years, 8 months ago by Weston Ruter.
    Thread Starter Civil Engineering Notes

    (@civilenggnotes)

    should I use “<amp-addthis>…</amp-addthis>”; code like the below??

    <amp-addthis
    width=”320″
    height=”92″
    data-pub-id=”ra-5c191331410932ff”
    data-widget-id=”mv93″
    data-widget-type=”inline”>
    </amp-addthis>

    Because when I am trying to put this code or the code provided by addthis widget, it is showing an “syntext error, unexpected T_LNUMBER” in the functions.php file

    Thread Starter Civil Engineering Notes

    (@civilenggnotes)

    Now I am confused about the header code. I used the following code in child theme’s functions.php file. Is it okay??
    /**
    * Implement the addthis amp header.
    */
    add_action( ‘amp_post_template_head’, function() {
    ?>
    <script async custom-element=”amp-addthis”
    src=”https://cdn.ampproject.org/v0/amp-addthis-0.1.js”></script&gt;
    <?php
    } );

    Thread Starter Civil Engineering Notes

    (@civilenggnotes)

    the buttons at the ends of the content will also work, but I was expecting to add in before or both

    Plugin Author Weston Ruter

    (@westonruter)

    If you put the tag in the content you do not need to add anything to the head, as the plugin will then do it automatically for you.

    Thread Starter Civil Engineering Notes

    (@civilenggnotes)

    but the tag in the content is showing the above error. please give an example of the line
    $content .= “<amp-addthis>…</amp-addthis>”; // Add the desired attributes.
    when i am putting the addthis widget code, it is showing “syntext error, unexpected T_LNUMBER” error. And when i am using the width, hight, type etc, still it is not showing

    Plugin Author Weston Ruter

    (@westonruter)

    add_filter( 'the_content', function( $content ) {
    	if ( function_exists( 'is_amp_endpoint' ) && is_amp_endpoint() ) {
    		$content .= "\n\n";
    		$content .= '<amp-addthis width="320" height="92" data-pub-id="ra-5c191331410932ff" data-widget-id="mv93" data-widget-type="inline"></amp-addthis>';
    	}
    	return $content;
    } );
Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Share buttons are not showing on AMP Pages’ is closed to new replies.