Skip to content

Instantly share code, notes, and snippets.

@farinspace
Forked from fchouquet/videos_projects
Created December 17, 2011 18:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save farinspace/1491041 to your computer and use it in GitHub Desktop.
Save farinspace/1491041 to your computer and use it in GitHub Desktop.
Can't get videos working
<?php global $video_metabox; $video_metabox->the_meta(); ?>
<?php if ( $video_metabox->have_value( 'vids' ) ) { ?>
<ul class="project_videos">
<?php while( $video_metabox->have_fields('vids') ) { ?>
<?php echo wp_oembed_get( $video_metabox->the_value( 'videourl' ) ); ?>
<?php } ?>
</ul>
<?php } ?>
<?php global $wp_embed, $video_metabox; $video_metabox->the_meta(); ?>
<?php if ( $video_metabox->have_value( 'vids' ) ) { ?>
<ul class="project_videos">
<?php while( $video_metabox->have_fields('vids') ) { ?>
<?php do_shortcode( $wp_embed->run_shortcode( '[embed]' . $video_metabox->the_value( 'videourl' ) . '[/embed]' ) ); ?>
<?php } ?>
</ul>
<?php } ?>
@fchouquet
Copy link

Thanks Dimas,

Actually I tried this before and it only displays video's URL, nothing is embedded.

It seems that it does not work with do_shortcode. We should instead use wp_oembed_get, what do you think ?

http://www.deluxeblogtips.com/2011/11/show-youtube-video-outside-post.html

@farinspace
Copy link
Author

The wp_oembed_get solution seems like it is best suited for this case, thanks for the tip!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment