Envira Gallery Blog

Digital Photography Tips, Tutorials and Resources

Make Shortcodes work in your WordPress sidebar widgets

How to Make Shortcodes Work in Your WordPress Sidebar Widgets

Last updated on Jul 30, 2016 by Waseem Abbas

Do you want to add shortcodes in your WordPress widgets? Sometimes you may want the convenience of using shortcodes to add new functionality to your sidebar. In this article, we will share how to make shortcodes work in your WordPress sidebar widgets.

Shortcodes are a simple method to add any functionality in WordPress: all you have to do is add a very short line of code, and you can create pretty much anything. Shortcodes work easily with the text editor in WordPress posts or pages. However, by default, WordPress sidebar widgets don’t support shortcodes.

One would think that shortcodes should work with the text widgets in sidebar. However, any text that you add in a text widget passes through WordPress filters that don’t allow shortcodes to work.

If you try to enter a shortcode into a text widget, you’ll end up with something like this:

Shortcode in Sidebar

However, you can enable shortcodes for the text widget in WordPress. Here’s how…

Making Shortcodes Work in Your WordPress Sidebar

There are two simple methods to make shortcodes work in your WordPress sidebar widgets: with a plugin, or using code.

Method 1: Using a Plugin

First thing you need to do is go to Plugins » Add New and type Shortcode Widget in the search bar. Press the Enter key.

Search Plugin

You should click on the Install Now button to activate the Shortcode Widget plugin.

Install Plugin

On the next page, you can simply click on the Activate Plugin link to activate this plugin.

Activate Plugin

Upon activating the plugin, go ahead to Appearance » Widgets and from the available widgets, select and drag the Shortcode Widget to the sidebar widget area.

Shortcode Widget Plugin

You can add your shortcode in the text editor of this widget and hit the Save button. It will add the functionality of the shortcode in the sidebar widget in WordPress.

Method 2: Using the Code

With the code method, you can edit your theme’s function.php file and simply add this code:


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

It will create a new filter that surpasses the shortcodes in the text widget in WordPress, so they’ll work.

Simply go to Appearance » Widgets and add a text widget in the sidebar widget area. Then add your shortcode in the text widget and press the Save button.

Shortcodes Work in your WordPress sidebar widget

Now your shortcodes will work in WordPress sidebar widgets.

We hope this article has helped you to learn how to make shortcodes work in your WordPress sidebar widgets. You may also want to check out our guide on how to create an image widget in WordPress.

If you like this article, then please follow us on Facebook and Twitter for more free WordPress tutorials.

Using WordPress and want to get Envira Gallery free?

Envira Gallery helps photographers create beautiful photo and video galleries in just a few clicks so that they can showcase and sell their work.

Add a Comment

We're glad you have chosen to leave a comment. Please keep in mind that all comments are moderated according to our privacy policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.