Shortcodes are a great way to add layouts and functionality to your WordPress posts or pages. However the Text Widget that comes with WordPress does not by default support the use of shortcodes. The good news is you can add a filter to your functions.php file to accomplish this.
Before you modify your functions.php file make sure you make a backup.
Here’s the filters that we’ll add to the functions.php file:
add_filter( 'widget_text', 'shortcode_unautop');
add_filter( 'widget_text', 'do_shortcode');
Add this code at the bottom of your functions.php file. You can download your functions file and use a code editor or you can do this via the WordPress dashboard by going to Appearance > Editor and then clicking on the functions.php file in the file list on the right side of the editor. Add this code and then click “Update File”.
As you can see this is a very easy way to allow the use of Shortcodes inside the Text Widget.
What do you think of this tutorial? Did it work for you? Share your comments below. Thanks for reading!