Skip to content

Instantly share code, notes, and snippets.

@robobobo
Created February 19, 2018 19:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save robobobo/937e477ffaf59ea3f65762d3c5620d8a to your computer and use it in GitHub Desktop.
Save robobobo/937e477ffaf59ea3f65762d3c5620d8a to your computer and use it in GitHub Desktop.
How to add a div around Wordpress embeds using the oembed filter
function worpress_responsive_embeds($html)
{
if (stripos($html, "twitter") !== FALSE || stripos($html, "facebook") !== FALSE) {
return '<div class="social-embed-container">' . $html . '</div>';
}
else {
return '<div class="video-container">' . $html . '</div>';
}
}
add_filter('embed_oembed_html', 'wordpress_responsive_embeds', 10, 3);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment