I have a problem with a shortcode that I created to insert the facebook like button on my site, when this is called from amp pages. The shortcode created is nothing but the code indicated by the developers page on facebook. On the classic pages of the site it works well, but since it includes javascript code this shortcode makes the respective amp page invalid. To insert the button in the amp pages you must follow the directives indicated here: https://amp.dev/documentat…/…/components/amp-facebook-like/… and actually the button works. But how do I use the same shortcode for both versions (amp and non amp)? I can't even create a new shortcode because when I write the article which one do I insert?
This is on wordpress site version 5.1
Code for classic page
<!-- Load Facebook SDK for JavaScript -->
<div id="fb-root"></div>
<script>(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "https://connect.facebook.net/en_US/sdk.js#xfbml=1&version=v3.0";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
<!-- Your like button code -->
<div class="fb-like"
data-href="https://www.your-domain.com/your-page.html"
data-layout="standard"
data-action="like"
data-show-faces="true">
</div>
Code for amp page
<script async custom-element="amp-facebook-like" src="https://cdn.ampproject.org/v0/amp-facebook-like-0.1.js"></script>
<amp-facebook-like width="110"
height="20"
layout="fixed"
data-layout="button_count"
data-href="https://www.facebook.com/testesmegadivertidos/">
</amp-facebook-like>