One of our OSTraining members was having an issue with shortcodes in widgets, so we created a tutorial for her.
By default, WordPress allows you to run shortcodes in many different places. You can use shortcodes in the text area of Posts and Pages. You can use shortcodes in WordPress emails.
However, by default, WordPress doesn’t execute shortcodes inside the default text widget. This tutorial will show you an easy way to get shortcodes working in widgets.
The image belows show the problem we face. We put a shortcode into a widget, but it shows up as plain text.
Let’s install a plugin to fix this.
- Install and enable the Shortcode Widget plugin
- Go to Appearance > Widgets.
- You’ll now see a new widget type called “Shortcode Widget”.
- Add the Shortcode Widget to your sidebar:
- On the right side, you can now add your [shortcode] to your Shortcode Widget’s content:
- Check your front-end and the shortcode will now. That’s all there is to it. Enjoy!
Shortcode Pro Tip
You can execute shortcodes in the regular WordPress text widget by adding the following code to your functions.php file of your child theme: