I believe this will allow iframes through wp_kses_post, but I haven't personally tried it. source
/**
* Add iFrame to allowed wp_kses_post tags
*
* @param array $tags Allowed tags, attributes, and/or entities.
* @param string $context Context to judge allowed tags by. Allowed values are 'post'.
*
* @return array
*/
function custom_wpkses_post_tags( $tags, $context ) {
if ( 'post' === $context ) {
$tags['iframe'] = array(
'src' => true,
'height' => true,
'width' => true,
'frameborder' => true,
'allowfullscreen' => true,
);
}
return $tags;
}
add_filter( 'wp_kses_allowed_html', 'custom_wpkses_post_tags', 10, 2 );
Just to flag though - due to a comment on this answer - this isn't the best way to go about adding video to post content. If you're using Gutenberg, there are native embed blocks, and post_content should be able to parse it without any security vulnerabilities. Or you could create an ACF block for your embed code using the acf oembed field, and utilize block parsing to create your excerpt.
post_content
when you should be requesting thepost_excerpt
.