Auto-embed URL in Text widget


By default, WordPress does not allow you to auto embed a URL in a Text widget. You can autoembed into a post or a page by default.

The following php code was added to the functions.php file in the WordPress child theme.

// To be able to put an auto-embed URL into a Text widget just as 
// you can in a post or page, the following two lines of code are 
// entered here. Source: page 501 of WordPress The Missing Manual 
// Second Edition by Matthew MacDonald.
add_filter('widget_text', array($wp_embed, 'run_shortcode'),8);
add_filter('widget_text', array($wp_embed, 'autoembed'),8);