How to wrap oEmbed-embedded video in DIV tags inside the_content?

The embed_oembed_html filter runs before an oEmbed resource’s HTML is outputted, so you could hook into this and wrap the output in a div as below. I can’t think of a simple way of wrapping the other content.

add_filter('embed_oembed_html', 'my_embed_oembed_html', 99, 4);
function my_embed_oembed_html($html, $url, $attr, $post_id) {
  return '<div id="video">' . $html . '</div>';
}

Leave a Comment