Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I am making a Wordpress Theme for a website with video tutorials. I would like to put the video that is embedded in the content (with oEmbed) in a apart div.

An example

The full content (output from the_content()) is something like this:

<p><iframe src="http://player.vimeo.com/video/0000000" width="900" height="506" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe></p>
<p>This is an Test of a tutorial. Bla bla bla</p>

And I would like to get this to:

<div id="video">
<iframe src="http://player.vimeo.com/video/0000000" width="900" height="506" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>
</div>
<div id="content">
<p>This is an Test of a tutorial. Bla bla bla</p>
</div>
share|improve this question
    
What have you tried? –  Colin May 1 '12 at 15:57
    
I have tried to split it via a regex, but it became a mess. –  TV productions May 1 '12 at 15:58
add comment

migrated from stackoverflow.com May 1 '12 at 16:53

This question came from our site for professional and enthusiast programmers.

2 Answers

up vote 3 down vote accepted

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>';
}
share|improve this answer
add comment

If you are attempting to use oEmbed in your Wordpress theme template, try this:

<aside>
    <p>oEmbed video in template test</p>
    <?php echo apply_filters('the_content', "http://vimeo.com/41205967"); ?>
</aside>

This snippet will display a video from Vimeo.com directly in your theme, without having to create a post manually.

share|improve this answer
    
The video's are embedded in posts. That was the problem. –  TV productions May 1 '12 at 17:11
add comment

Your Answer

 
discard

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.