I had a client ask me if I could make the WooCommerce description field for products behave like the default body text editor, in that when he pasted a YouTube link, it would automagically appear in the content. This functionality, called oEmbed, allows editors to easily drop videos, tweets, and other external media directly into WordPress.

The easy embedding feature is mostly powered by oEmbed, a protocol for site A (such as your blog) to ask site B (such as YouTube) for the HTML needed to embed content from site B. oEmbed was designed to avoid the need to copy and paste HTML from the site hosting the media you wish to embed. It supports videos, images, text, and more.

Here’s the quick snippet on how you can accomplish this; just drop it in your theme’s functions.php file to apply the fix to the WooCommerce short description field (or replace with another field you want):

// Apply WP content filter to WooCommerce short description field (oEmbed support)
global $wp_embed;
add_filter( 'woocommerce_short_description', array( $wp_embed, 'autoembed' ), 8 );

Voilà!

Continue Reading