I’m in the process of finalizing a content curation WordPress plugin, and this little tidbit just saved me some time. WordPress has automatic video embedding functionality provided by oEmbed for the_content(), but not the the_excerpt() or get_the_meta(). In order to display a YouTube video from a Google Reader RSS feed, I needed to add this filter to the_excerpt(). This could easily be used on get_the_meta() also.

oEmbed & Excerpts

Adding the following bit of code to your functions.php will enable oEmbed filtering for the_excerpt():

add_filter('the_excerpt', array($GLOBALS['wp_embed'], 'autoembed'), 9);

oEmbed & Custom Fields

Adding the following bit of code to your functions.php will enable oEmbed filtering for get_the_meta():

add_filter('get_post_metadata', array($GLOBALS['wp_embed'], 'autoembed'), 9);

That’s it!

About the Author

Kevin Leary is a freelance developer in Boston, MA with a strong portfolio of work, and over 13 years of experience as a programming consultant and digital strategy provider. Interested in working together? Hire me for your next project.