close
widgetsshortcodes

One of the most asked question in the world of WorldPress is add shortcodes in sidebar widgets. Shortcodes does not work in the sidebar widgets by default. This article will explain how to easily use shortcodes in your WordPress sidebar widgets.

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.

Beginners often 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.

shortcode-issue

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

Install and activate Shortcode Widget plugin. Once activated 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.

shortcodeinwidgets

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

1// Enable shortcodes in text widgets

 

2add_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.

 

 

 

 

Tags : wordpressWordPress how to
Nooruddin Ahmed

The author Nooruddin Ahmed

An avid football fan. Lives for the weekend game.Aviation enthusiast. Believes in letting bygones be bygones.

Leave a Response