Why Shortcodes Doesn’t Work in WordPress Widgets?

In WordPress, shortcodes provide an easier way to add functionality in text areas like post editor when you are writing a post.

Often beginners think that because there’s a text widget in your sidebar, shortcodes will automatically work. By default, any text entered into the text widget goes through WordPress filters which doesn’t allow shortcodes to be executed.


Instead of seeing the final result, you will see the shortcode itself as plain text.

It is very easy to change that, and we will show you how to easily enable shortcodes to be executed in WordPress text widgets.

Method 1: Adding Shortcode Enabled Text Widget in WordPress

In this method, we will be using a simple WordPress plugin. This method is recommended for beginners who don’t want to add code manually.

First thing you need to do is install and activate the Shortcode Widget plugin.

Upon activation, you need to visit Appearance » Widgets page. There you will find a shortcode widget in the list of available widgets.

Simply add the shortcode widget to a sidebar and then add your shortcode in the content box. Don’t forget to click on the save button to store your widget settings.

shortcode widget

This shortcode widget is just like the default text widget in WordPress. The only difference is that you can add shortcodes inside it.

Method 2: Enabling Shortcodes in WordPress Text Widget

If you are comfortable adding code to your theme, then you can enable shortcodes to work in text widgets.

Simply add this code to your theme’s functions.php file or a site-specific plugin.

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

This code simply adds a new filter allowing shortcodes to run inside text widget.

You can now visit Appearance » Widgets page and add a text widget to a sidebar. Paste the shortcode in the content box and click on the save button.

Visit your website to see shortcode working inside text widgets.

Shortcode working in WordPress widget

We hope this article helped you learn how to use shortcodes in your WordPress sidebar widgets. You may also want to see our list of 7 essential tips for using shortcodes in WordPress.

Previous articleBluetooth 5 spec will double speeds and quadruple range
Next articleHow to Setup Facebook Instant Articles for WordPress
Technewborn is a leading problogging platform that covers the latest in technology, news, social media, mobile industry, apps, games, and more. I have been researching, writing, reading, living in it since 2009. I try adding a unique taste to whatever techy I write. You can follow me on below Social Network