Ever faced a problem when you tried to attach any shortcodes to the sidebar of your WordPress website? Did it output a result like below image?
If so, we have the solution for you. Continue reading this article to find out, how to use shortcodes in WordPress sidebar without getting any errors.
Why Shortcodes not working in Text widget?
If you think. Ha, yes. I just have to enter the shortcode to the text widget as I do in the visual composer, or inside the posts, you got it wrong. By default, WordPress widget has a filter that filters out the shortcodes and uses it as plain text. So, you should bypass this to make your shortcodes working in widget areas.
Method to Use Shortcodes in WordPress Sidebar Widgets
If you ever wanted to use the shortcodes in your sidebar widget, just open the functions.php file of your theme and place the following code there.
// Enable shortcodes in text widgets
add_filter('widget_text','do_shortcode');
Now, you can visit Appearance > Widgets to place your shortcodes in the text editor widget that comes default with the WordPress.
It will work for you and now, the shortcodes will be working fine in your WordPress widget areas. If you faced any problems or need further help, feel free to drop a comment. We will get back to you ASAP.