WP Video Popup builds the embed URL for you from the video link in your shortcode. Besides the built-in shortcode attributes, you can add any other YouTube, Vimeo or Rumble player parameter with the wp_video_popup filter.
This guide is for developers. Add the code to your child theme’s functions.php or a code snippets plugin.
How the filter works
The filter receives the finished embed URL, for example:
https://www.youtube.com/embed/YlUKcNNmywk?autoplay=1
The URL already contains parameters, so always add yours with &. Whatever your function returns is used in the popup.
Example: show YouTube captions by default
function prefix_wp_video_popup_parameters( $video_url ) {
$video_url .= '&cc_load_policy=1';
return $video_url;
}
add_filter( 'wp_video_popup', 'prefix_wp_video_popup_parameters' );
The embed URL then looks like this:
https://www.youtube.com/embed/YlUKcNNmywk?autoplay=1&cc_load_policy=1
Example: different parameters per platform
The filter runs for every video, so check the URL if a parameter only exists on one platform. This example shows YouTube captions and sets a custom player color for Vimeo:
function prefix_wp_video_popup_parameters( $video_url ) {
if ( false !== strpos( $video_url, 'youtube' ) ) {
$video_url .= '&cc_load_policy=1';
}
if ( false !== strpos( $video_url, 'vimeo' ) ) {
$video_url .= '&color=ff0000';
}
return $video_url;
}
add_filter( 'wp_video_popup', 'prefix_wp_video_popup_parameters' );
All available parameters: YouTube player parameters and Vimeo player parameters.