For a WordPress site I am working on, there is a jquery slider (based on the coda slider) where videos are presented. All of the videos are from Vimeo. If a video is playing and someone slides to the next video, the other video continues to play. I have found some API code from Vimeo that allows me to control the video, so i could possibly add a "pause" class to the slider buttons that will pause videos when someone slides to the next video.

However; in order for this to work, I need an id added to the iframe tag, and this line of code to the end of the video player url: ?api=1&player_id=player_1 (except player_1 should be a unique id)

So the final output should look like this (except player_id number will be unique on each video):

<iframe id="player_1" src="http://player.vimeo.com/video/27421766?api=1&amp;player_id=player_1" width="670" height="377" frameborder="0" webkitAllowFullScreen allowFullScreen></iframe>    

I wonder if there is a function I can create that will do this. I know there are some core files in WordPress where the embed code lives, but am hestitant to mess with that.

  • Okay. I am on the slow track to solving this. .. Oct 20, 2011 at 18:05

2 Answers 2


I add a frame ID using an each function's index, and then appending the src with the string you need:

jQuery('#video-gallery-list li.video-player').each(function(i) {
    // set up a variable for the src that includes the new unique ID you're about to use
    var this_src = jQuery(this).find('iframe').attr('src') + '?api=1&amp;player_id=player_'+i;
    jQuery(this).find('iframe').attr('ID', 'player_'+i).attr('src',this_src);

Okay, by much digging around I was able to find a patch someone had created for the class-oembed.php file in WordPress that allows for additional arguments to be sent to oEmbed (normally you are only able to send the "Width" and "Height". The patch I found here: http://core.trac.wordpress.org/attachment/ticket/16996/16996-2.diff
Using that was able to send additional arguments oEmbed along with the URL like so:

return $wp_embed->shortcode( array('width' => $width, 'height' => $height, 'api' => 1, 'player_id' => $postID), $videoURL );

I still have not found a way to return an ID for the iframe, but I THINK that I can work around that because in my particular instance I do not need to choose one particular Video on a page...I just need to create a button that will pause all videos that are running.

  • I just updated my answer as I realized I didn't actually answer your question. Use the each command with the index, and apply the player_[index] id. See above.
    – Will Lanni
    Mar 19, 2015 at 0:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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