So Is it the iframe or AMP-Iframe that you are inserting (also share the code if possible) and where exactly?
So I will also try to re-create it and If the issue occurs which I am sure it will, then I will try to solve it and release immediately.
Hi Ahmed!
Here’s the code I insert at the bottom of my pages:
<amp-iframe width="200" height="300"
sandbox="allow-scripts allow-same-origin allow-forms"
layout="responsive"
frameborder="0"
src="https://youcanbefound.com/wp-content/js/thc_contact.html">
<amp-img layout = "fill" src = "/wp-content/uploads/2019/08/loading.gif" placeholder></amp-img>
</amp-iframe>
Now, in the past I didn’t use an image placeholder. So when pages were not long enough, the iframe doesn’t load, and the amp for wp plugin doesn’t load the amp iframe extension library (https://cdn.ampproject.org/v0/amp-iframe-latest.js). Now, since I added the placeholder, I don’t need the content requirement anymore. But it still won’t show because amp for wp doesn’t load the amp iframe extension library for all pages (I’m assuming it only loads it for pages with long enough content).
So is there a way to have it load all the time? I have to force it now, but for pages that load it automatically, it loads twice.
I understood your issue. We can definitely fix this but I just need one last answer:
Where exactly are you inputting the code? (Classic Editor, Gutenberg code module, AMP page builder, Widget or somewhere else?)
Kindly provide the screenshot of the input so I can be 100% accurate with the solution.
Hi Ahmed!
I added the script via an action hook in functions.php:
add_action('amp_post_template_above_footer','contact_form_code');
function contact_form_code() {
$contactscript = '<amp-iframe width="200" height="300"
sandbox="allow-scripts allow-same-origin allow-forms"
layout="responsive"
frameborder="0"
src="https://youcanbefound.com/wp-content/js/thc_contact.html">
<amp-img layout = "fill" src = "/wp-content/uploads/2019/08/loading.gif" placeholder></amp-img>
</amp-iframe>';
echo $contactscript;
}
Let me know if you need anything else.
Thank you!