Enable Shortcodes in WordPress Text Widget

In WordPress, shortcodes provide an easier way to add functionality in pages and posts areas of your website. By default, shortcodes do not work within sidebar and footer widgets.

Sometimes, theme designers add the functionality. Other times you may need to do it yourself.

Luckily it’s an easy WordPress Hack to¬†enable shortcodes within a WordPress Text Widget. Just add the following code to your Theme Functions (functions.php) file:

// Enable shortcodes in text widgets
add_filter('widget_text','do_shortcode');

That’s it. Just one description line and one line of code.

Once the modified functions file is saved, add a Text Widget to a sidebar, add your desired shortcode, and you should be good to go.

Leave a Reply

Your email address will not be published. Required fields are marked *