In WordPress, how can I use the embed video feature via a custom shortcode?
I have tried the following, but that does not actually embed the video. It just adds an empty <div class="aligncenter"></div>
to the html?
function shortcode_vimeo($atts) {
extract(shortcode_atts(array(
"id" => '',
"align" => 'aligncenter'
), $atts));
return '<div class="'.$align.'">' .
do_shortcode('[embed]http://www.vimeo.com/'.$id.'[/embed]')
.'</div>';
}
add_shortcode("vimeo", "shortcode_vimeo");
Embedding videos seems to not work with do_shortcode
. However, I have now found the following solution:
global $wp_embed;
$video_embed = $wp_embed->run_shortcode('
[embed]http://www.vimeo.com/'.$id.'[/embed]'
);