Ben
Ben

Reputation: 16659

Embed video with custom shortcode

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");      

Upvotes: 1

Views: 1893

Answers (2)

Sugi Kim
Sugi Kim

Reputation: 1

IM USE http:// playerdrive. com .. easy to use

The system draws a link that can repair links automatically expire. Available in both Jwplayer 6.x and jwplayer 7.x and prompted a broken link. Player skins with a beautiful 37 (for jwplayer 6.x) and 9 (for jwplayer 7.x), you have to choose. Animations can be pulled from Google's video was played before posters. It also supports applications on smartphones for all screen sizes. Protect Bringing in a given domain and. Can provide multiple site as needed.

Upvotes: 0

Ben
Ben

Reputation: 16659

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

Upvotes: 3

Related Questions