How can I add shortcodes in WordPress sidebar widgets? That seems to be a very common question that Ive heard plenty of times. By default shortcodes do not work in sidebar widgets. In this post I will show you how to easily use shortcodes in your WordPress sidebar widgets.
Why Shortcodes Don’t Work in WordPress Widgets?
Shortcodes provide a simplier way to add functionality in text areas like post editor when you are writing a page or post.
Often people just starting out 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 what you woud expect to see, the shortcode will show as plain text.
It is very easy to change that, and I will show you how to easily enable shortcodes to be executed in WordPress text widgets.
Adding Shortcode Using A Plugin
If your new to WordPress and dont want to mess around with any code you can use a WordPress plugin that will allow shortcodes to execute the way you would expect.
What you need to do is to install and activate the Shortcode Widget plugin.
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.
This shortcode widget is just like the default text widget in WordPress. The only difference is that you can add shortcodes inside it.
Option 2: Enabling Shortcodes in WordPress Text Widget
Simply add this code to your theme’s functions.php file or a site-specific plugin.
This code simply adds a new filter allowing shortcodes to run inside text widgets.
Visit your website to see shortcode working inside text widgets.
I hope you found this post insightful. Please share!