Use Shortcodes in WordPress Text Widgets

One of the most common question I get ever since I worked as a WordPress developer is on how to enable shortcodes in Text widgets. By default the Text widget does not execute a shortcode. Here’s what you need to do.
Add this to your functions.php file:

add_filter( 'widget_text', 'do_shortcode');

Now you’ll be able to use shortcodes within Text widgets.