Personally, I found the oembed_dataparse filter pretty fiddly to use; sometimes it worked, sometimes it didn’t; and when used in conjunction with custom TinyMCE instances, it seems as though the added wrapper was hard-baked into the content rather than added via the filter at output.
I found the embed_oembed_html filter much more reliable and works every time:
function vnmFunctionality_embedWrapper($html, $url, $attr, $post_id) {
return '<div class="embedwrapper">' . $html . '</div>';
}
add_filter('embed_oembed_html', 'vnmFunctionality_embedWrapper', 10, 4);
Note that this will wrap all oEmbeds. If you wanted to target YouTube specifically:
function vnmFunctionality_embedWrapper($html, $url, $attr, $post_id) {
if (strpos($html, 'youtube') !== false) {
return '<div class="youtubewrapper">' . $html . '</div>';
}
return $html;
}
Related Posts:
- How add class youtube and type/html to oembed code?
- YouTube oEmbed and privacy-enhanced mode
- oEmbed youtube video aspect ratio
- WordPress, oEmbed & YouTube video’s with a ‘dash’
- YouTube: How to extract closed caption transcript from YouTube video?
- Is there a way to get all IP addresses of youtube to block it with Windows Firewall?
- YouTube maxresdefault thumbnails
- Youtube – downloading a playlist – youtube-dl
- URL syntax for Youtube video in fullscreen and start at time index
- How to customize an end time for a YouTube video?
- How can I clear oEmbed caches for YouTube on posts as they are loaded
- How to Replace YouTube Videos with a “Click to Play” Thumbnail?
- Modify youtube video size on one page and show another size on different page
- Set wmode attribute to transparent for the embed shortcode to make drop-down menu hover over YouTube embed in Internet Explorer
- Manipulating oembed_dataparse stopped working for YouTube embeds
- Get all Youtube video’s from posts and embed them on a different page
- WordPress 5.3.x YouTube oEmbed is not working
- Use oEmbed in List Items
- Embeding YouTube video via a template function throws iframe cross-domain policy error
- Video Embed with Captions in Turkish
- Link Youtube Channel In WordPress Site
- Embed youtube list with sidemenu opened
- Getting youtube links from post_content not working
- How can I grab the video id of youtube?
- Add latest Youtube videos on main page [closed]
- oEmbed not working in WordPress
- How to apply an ID to Shortcode Embedded iframe
- How to embed YouTube videos in posts without adding suggested videos at the end?
- How do I embed a YouTube video in WordPress 3.0?
- Div around YouTube video
- Echo do shortcode with custom field not working
- YouTube API 403 error when website restriction set
- Add parameter to first post only
- Looking to Customize YouTube Video Embeds
- How to change src link in YouTube?
- How to make an image of a YouTube video appear as a thumbnail in the list of blog posts
- Is there a way to find all posts with Youtube video embedded?
- WordPress fails to embed video URL on specific theme
- How to add srcdoc attribute to YouTube oEmbed in Gutenberg oEmbed Block
- How to modify the HTML output of Gutenberg block? (Youtube)
- WordPress and Youtube problem
- Advanced Custom Fields oEmbed video width and height
- Iframe Youtube video doesn’t work
- WordPress Mediaelement – Youtube Videos Embed Options
- display only youtube video sticky post
- Generate a WP post from Youtube Feed
- Importing YouTube Videos As Posts – From Playlists
- Avoid embedding YouTube videos and open them in a new window
- add_filter is failing to append &rel=0 to end of YouTube URL in oEmbed
- Embbeded YouTube video not showing when admin logged in
- How do I get a YouTube video thumbnail from the YouTube API?
- Youtube_dl : ERROR : YouTube said: Unable to extract video data
- oEmbed, thumbnails and wordpress
- Correct regex for wp_embed_register_handler
- Being notified when some YouTube video in some post becomes unavailable
- Detecting Embed URLs Within post_content
- How to oEmbed from custom field, responsive to container size and responsive
- How to increase image size returned from Flickr oEmbed in Twenty Twelve theme
- Forcing oembeds to top of post
- Add parameters vimeo videos using wordpress embeds
- Filter oembeds tags to modify iframe attributes
- Removing WordPress Icon from oembed link footer
- oEmbed fails half of the times. Could I reload the request on fail?
- How do I display Youtube/Vimeo video ID on custom post type when user enters it in custom meta box?
- How to link to YouTube videos with thumbnails?
- wp_embed_register_handler to embed html files
- Post preview and oembed provider issue using polylang plugin with subdomains
- Display oEmbed in the_excerpt
- Use Auto Embed with get_post()
- How to center oEmbedded content
- Is there a built in function to see if a URLis oEmbed Compatible?
- How to import my YouTube channel into WordPress?
- pass user id in slug and get user information
- Is there any way to render the WordPress Gutenberg core/embed block in PHP by passing in the URL?
- YouTube Video autoplay
- How do I phpunit test a post output process?
- How to set up front end editor to autoembed media for non-logged in users?
- How to register a embed handler as a fallback to a oEmbed handler?
- Problem with oEmbed in some themes
- JSON in oembed not being internationalized (using QTranslateX)
- Feed error: A feed could not be found at youtube.com/… (1 post) [closed]
- How to allow YouTube object embed in WordPress 3+?
- WordPress get_media_embedded
- YouTube embeded video will not resize (only full screen responsive) [closed]
- What are available arguments for wp_oembed_get?
- Static image for embedded YouTube video instead of blank player?
- WordPress fails to embed video URL
- Publishing a video from blog to youtube
- Cannot display the_content() after removed WordPress 5’s auto embed feature (iframe & blockquote)
- Can’t embed certain youtube videos into theme
- Block editor: Sandbox iframe shows outdated HTML
- Get youtube link title in post title
- Printing OEmbed URL based on Post selected w/o page refresh
- jQuery plugin is loaded correctly, but does nothing
- Wrap iframes/embeds, but do it before oEmbed happens
- Filter for wp_embed_handler_youtube not working
- change output location of plugin function using a custom hook
- Conditionally enable autoplay when using oEmbed in a custom widget
- plugin to upload to youtube via wordpress [closed]
- Pull latest Youtube Video from json url and make new post