默认情况下,WordPress会删除iFrame。这就是为什么你可以在编辑器中看到它,但当你试图在网站上保存/发布它时却看不到它。
尝试通过将其添加到主题函数中来启用iframes。php文件
/**
* 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;
}