How to Use Shortcodes in your WordPress Sidebar Widgets

Over the recent times, the most asked question on WordPress is How to Use Shortcodes in your WordPress Sidebar Widgets? There are many theme plugins which provide you to add the shortcodes in the Pages and Posts but there is not widget shortcode that could be added. In WordPress by default even if you put the Shortcode in the text widget it will not work. Let’s take a look at how to add shortcodes in your WordPress Sidebar Widgets.
How to Use Shortcodes in your WordPress Sidebar Widgets

How to Use Shortcodes in your WordPress Sidebar Widgets

Most of the beginners try adding the shortcodes into the Text widget and expect to work. By default, all the text entered in the Text widgets will go through the WordPress filters which don’t allow shortcodes to be executed. Even if you try this option you will get the shortcode in a simple plain text.

There are basically two approaches where we could easily enable Shortcodes to be executed with the WordPress Text Widgets. Let’s take a look at details.

Adding Shortcode Enabled Text Widget in WordPress

In this approach, we will install a simple WordPress plugin which does the job for us. If you are new to WordPress then this is the best method to use without editing any PHP code manually.

Install the Shortcode Widget plugin and activate the plugin. Upon activation navigate to Appearance » Widgets page where you will see the shortcode widget in the available widgets list.

Drag and drop the Shortcode Widget wherever(Sidebar, Header, Footer) you require. Once you dropped the widget to right place give the Title and add the Shortcode in the Content box as shown in the below image.

How to Use Shortcodes in your WordPress Sidebar Widgets

You could add any shortcode in this Widget and it is very similar to the WordPress Text widget. Try out by Adding your favorite shortcode in this widget. Don’t forget to save the changes after adding the shortcode.

Recommended Article to read

Enabling Shortcodes in WordPress Text Widget

The second option is to enable the Shortcodes in the WordPress on the Text Widget itself. You could perform this by adding few lines of code in your function.php file which is located in your theme directory.

The above code will add a new filter which will allow WordPress to process the shortcodes in the Text Widgets. Once you have added this navigate to Appearance » Widgets and add the WordPress Text widget into the sidebar and place your shortcode in the widget box. Save the changes to see the shortcode in action.

Visit your website and you should be able to see the shortcode working properly inside the text widget.

You may also like...

Leave a Reply

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

CommentLuv badge