Shortcodes are one amazing feature of WordPress. With shortcodes, you can easily and quickly add anything to the visual editor of post and page. For those who don’t know, a shortcode is something that looks like this – [shortcode starts]My text here[/shortcode ends]. It works as programmed by the developer, to do a specific task such as adding a contact form, table, buttons and more. While shortcodes work great, and can be used in visual editor, if you add the same shortcode to the text widget then it won’t. That’s because shortcodes in text widgets is not enabled, by default, in WordPress. But don’t worry, there’s an easy way to enable shortcodes in widget area in WordPress.

Code Method

The text widget runs trough a filter called ‘widget_text’ which means you just need to enable it. Simply enter the below code in your functions.php file.

add_filter( 'widget_text', 'shortcode_unautop');
add_filter( 'widget_text', 'do_shortcode', 11);

That’s all you need to do. Now you can add shortcodes to widgets of sidebar, footer, or other areas.

Plugin Method

For those who don’t want to delve in coding (although it’s just about adding two simple lines of code to a file), here’s a plugin named as Shortcodes in Widgets.

Simply install this plugin and then activate it to execute shortcodes in sidebar text widgets. There’s nothing else that you need to do, apart from activating it.

[Download link]

Go ahead, use any of the above method and start enjoying the shortcode in widgets area in WordPress.

Leave a Reply

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