How to Enable Shortcodes in WordPress Text Widgets

kobu-agency-685117-unsplash

So, you want to use a shortcode, and you want to put it in a widget.  You probably found out that the shortcode doesn’t process, but instead displays the shortcode text on the page.  Lame, right?

Luckily there’s a really easy quick fix for this.

Simply add this code to your theme’s functions.php file

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

That’s it!  Now your shortcode actually gets processed and displays what you intended to display.

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments