Created
October 15, 2020 14:15
-
-
Save someguy9/41d5671383715176b859586dc636f300 to your computer and use it in GitHub Desktop.
Auto wrap YouTube video embeds in WordPress with a div
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter('embed_oembed_html', function ($html, $url, $attr, $post_id) { | |
if(strpos($html, 'youtube.com') !== false || strpos($html, 'youtu.be') !== false){ | |
return '<div class="responsive-embed-container embed-responsive-16by9">' . $html . '</div>'; | |
} else { | |
return $html; | |
} | |
}, 10, 4); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment