WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

My posts have YouTube embedded videos in the form of:

<object width="600" height="400" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="src" value="http://www.youtube.com/v/zN9mdItmoBs&amp;vq=hd720" /><embed width="600" height="400" type="application/x-shockwave-flash" src="http://www.youtube.com/v/zN9mdItmoBs&amp;vq=hd720" /></object>

How do I wrap a <div> around it?

I've tried adding the following to the functions.php file:

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>';

It doesn't work. What do I do?

share|improve this question
up vote 2 down vote accepted

I'm not sure why that's not working except maybe you need to put the returned stuff in a variable? This is what works for me when I put it in my functions.php file:

add_filter( 'embed_oembed_html', 'tdd_oembed_filter', 10, 4 ) ; 
function tdd_oembed_filter($html, $url, $attr, $post_ID) {
    $return = '<figure class="video-container">'.$html.'</figure>';
    return $return;
share|improve this answer
It still doesn't work. I'm using Twenty Thirteen if that helps. – markerpower Oct 19 '13 at 17:19
Michelle's code and yours works for me on WP 3.6 with no plugins installed on TwentyThirteen and any other default theme. – Wyck Oct 19 '13 at 18:11
I'm also using WP 3.6 and no plugins; it's a fresh install. All I do is edit the functions file right? I'm not sure what the problem is. – markerpower Oct 19 '13 at 22:25
How are you embedding the object? This may only work for the oembed method where you put the plaintext YouTube URL in the content on its own line and it auto-converts to an embedded object...? – Michelle Oct 19 '13 at 23:31
I put the embed code I posted above in a post under Text. – markerpower Oct 19 '13 at 23:39

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.