• Resolved David Elstob

    (@davwaiguy)


    When I add the Facebook like and comments scripts to a WordPress post, AMP removes them, even though I have the green light on the AMP Validator.

    As long as I leave the post on the code tab in classic version or HTML tab using Gutenberg everything is fine. You can view the post for days.

    But if I swap tabs from code tab to the writing tab and make a quick edit/update, when I save the post the Facebook components will be removed. Strange?

    It’s been doing the same thing on two different sites now.

    • This topic was modified 5 years, 8 months ago by David Elstob.

    The page I need help with: [log in to see the link]

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

    (@westonruter)

    @davwaiguy How are you adding the Facebook components to the page? Note that there is a fix coming in 1.1: https://github.com/ampproject/amp-wp/pull/1956

    I can see the Facebook comments form in https://sonicseo.co.uk/amp-wordpress-setup-guide/

    I can also see the Like button and Share button.

    Thread Starter David Elstob

    (@davwaiguy)

    I don’t put any scripts in header.php apart from adding the 2 x component items in each post as code.

    They have to be added manually each time so I can update the URLs.

    They are scripts, but the correct AMP version not the standard one.

    If there is a fix then that is all I need to know thanks.

    Plugin Author Pascal Birchler

    (@swissspidy)

    @davwaiguy Curious: since you say the components get removed when switching from the code tab to the writing tab – does this also happen with the AMP plugin being disabled?

    Thread Starter David Elstob

    (@davwaiguy)

    I’ve just tried with the plugin turned off and the code isn’t removed so it seems that it is definitely to do with the AMP plugin sanitising it.

    However, the code no longer works, but that’s obviously because the AMP plugin is off.

    Thanks for the quick answers – you lads really are the best about!

    Plugin Author Weston Ruter

    (@westonruter)

    @davwaiguy I don’t understand. What is the specific code you are adding to the page for Facebook comments and likes?

    Thread Starter David Elstob

    (@davwaiguy)

    Hi Weston,

    For the follow buttons, the code doesn’t change so I can put that in single.php (post template). With the Facebook components, because they need the URL to be the same as the actual post that people are liking or commenting on, I have to place the code in the individual post and alter the URL to match.

    For example:

    <amp-facebook-like width=486 height=35
    layout=”fixed”
    data-layout=”standard”
    data-size=”large”
    data-share=”true”
    data-href=”https://gossiplolly.com/fbi-ten-most-wanted/”&gt;
    </amp-facebook-like>

    And:

    <amp-facebook-comments width=486 height=657
    layout=”responsive”
    data-numposts=”5″
    data-href=”https://gossiplolly.com/fbi-ten-most-wanted/”&gt;
    </amp-facebook-comments>

    I’ve just carried this practice over from before when my site was pre-AMP, but have updated the two scripts above to AMP Facebook components rather than standard Facebook components.

    This seems like the only way you can do it with WordPress, unless you have an alternative idea?

    It does work fine, apart from when I change from the coding back end of the post to the written back end of the post or simply try and update my posts.

    Appreciate your time. Thanks.

    Thread Starter David Elstob

    (@davwaiguy)

    Hi Weston,

    I’ve tested the new plugin and it appears to work perfectly. When I switched numerous times between the visual editor and the code editor, as it’s now called in Gutenberg, the comments were not stripped out.

    Great stuff!

    Plugin Author Weston Ruter

    (@westonruter)

    Ok, so I guess this is resolved?

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘AMP still removing Facebook components’ is closed to new replies.