admin管理员组文章数量:1333201
I have tried to add the following code using a 'Custom html' block (to embed a GiveNow donation form). It shows as a preview on the page however when I attempt to view it on the live website, it is not visible:
<div style="padding:1px;max-width: 700px"><iframe class="gn-iframe" src="; height="870" style="width: 100%" frameborder="0"></iframe></div>
I have read through other help responses to similar issues but can't figure out what I'm doing wrong.
Thanks in advance, Lauryn
I have tried to add the following code using a 'Custom html' block (to embed a GiveNow donation form). It shows as a preview on the page however when I attempt to view it on the live website, it is not visible:
<div style="padding:1px;max-width: 700px"><iframe class="gn-iframe" src="https://www.givenow.au/embed/Y2F1c2VpZD04MTImZG9tYWluPWxpZmUtZ2F0ZS5vcmcmdG9rZW49ODEyOjZhMGFhNmQyYzZiZTM2ZTk%3D" height="870" style="width: 100%" frameborder="0"></iframe></div>
I have read through other help responses to similar issues but can't figure out what I'm doing wrong.
Thanks in advance, Lauryn
Share Improve this question edited Jul 10, 2020 at 1:24 Jacob Peattie 44.1k10 gold badges50 silver badges64 bronze badges asked Jul 10, 2020 at 1:17 Life-Gate IncLife-Gate Inc 1 5- 1 It's possible that it's being hidden or squashed by your theme. I you inspect the HTML of the published page, can you see these elements, or are they missing entirely? – Jacob Peattie Commented Jul 10, 2020 at 1:25
- I'll check! Thanks for the tip Jacob :) – Life-Gate Inc Commented Jul 10, 2020 at 3:23
- Hi Jacob, I'm not brilliant with this stuff, but it looks to me like the coding I embedded is missing entirely from the HTML of the published page :/ – Life-Gate Inc Commented Jul 10, 2020 at 3:36
- When you save the post and come back is the HTML block empty, or is it still saved with the post? – Jacob Peattie Commented Jul 10, 2020 at 5:34
- Hi Jacob, when you save the post, exit it and then go back in, the above code is changed in the HTML block and all that remains is this: <div style="padding:1px;max-width:700px;"></div> – Life-Gate Inc Commented Jul 17, 2020 at 2:00
1 Answer
Reset to default 0WordPress strips out iframes by default. Which is why you can see it in the editor but not when you try to save/publish this on your site.
Try enabling iframes by adding this to your themes functions.php file
/**
* Add iFrame to allowed wp_kses_post tags
*
* @param string $tags Allowed tags, attributes, and/or entities.
* @param string $context Context to judge allowed tags by. Allowed values are 'post',
*
* @return mixed
*/
add_filter( 'wp_kses_allowed_html', 'allow_iframe_in_editor', 10, 2 );
function allow_iframe_in_editor( $tags, $context ) {
if( 'post' === $context ) {
$tags['iframe'] = array(
'allowfullscreen' => TRUE,
'frameborder' => TRUE,
'height' => TRUE,
'src' => TRUE,
'style' => TRUE,
'width' => TRUE,
);
}
return $tags;
}
版权声明:本文标题:embed - Why does my custom html code (for a donation form) appear in a preview but not in the published post? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742277041a2445390.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论