Ever faced a problem when you tried to attach any shortcodes to the sidebar of your WordPress website? Did it output a result like the below image? Then this article is for you. We will teach you how you can successfully input shortcodes to your WordPress website sidebar and be able to enjoy the functionality of the shortcode. As more and more plugins provide shortcodes to be used all across the WordPress CMS, it would be a good idea learning how to use shortcodes properly.
Continue reading this article to find out, how to use shortcodes in WordPress sidebar without getting any errors.
Reasons to use shortcodes in sidebar widgets
There are several reasons why you might want to use a shortcode in a WordPress sidebar widget. We are listing some of them below –
- A shortcode is extremely easy to use, all you have to do is copying and pasting the given shortcode to a text widget.
- Because shortcodes are extremely easy to use, all it takes is a few seconds to set it up.
- Shortcodes are usually provided by plugins with consistent styling and formatting, which means you can maintain the same style across the pages.
- Whatever you can do with PHP programming can also be accomplished by placing shortcodes. They are essentially PHP code wrapped inside.
- You can create your own shortcodes with whatever functionality you need without editing your team files.
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, the WordPress widgets have 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
There are multiple ways you can enable shortcodes on your word process sidebar widgets. Makes sure to follow them in the same order as mention the below to avoid any complicated steps just for a simple functionality.
Method 1. Using shortcode widget
Newer versions of WordPress come with a default shortcode widget which you can simply drag and drop to the desired location on your sidebar. In order to add a shortcode widget on your WordPress sidebar –
- Navigate to Appearance > Widgets.
- Search for “shortcode” among the widgets.
- Drag and drop it to the desired location.
- Input your shortcode [like-so].
Method 2. Using WordPress Full-Site Editor
WordPress Full-Site Editor allows you to design your website in a block styled manner. You can do all the customizations without any block editor plugins. All you have to do is adding a shortcode block to the sidebar in the block editor template, and then input your short code inside the shortcode widget.
Keep in mind that in order for this method to work, you should be using a block editor supported theme.
Method 3. Using the filter (On older WordPress versions)
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.
Now, the shortcodes will be working fine in your WordPress widget areas.