If you’ve read a handful of my blog posts, you’ve probably noticed that I like to use WordPress shortcodes. Whenever I am faced with a problem, the first place I look to solve it is with a custom shortcode.
Recently, I came across a situation where I needed to use a shortcode in a sidebar widget area. If you are a WordPress developer, you know that by default shortcodes don’t work in widgets. This has to do with the order that WordPress processes the PHP scripts on the server.
The good news is that it is possible to use shortcodes in WordPress widgets. In fact, it’s really easy. All you have to do is add one line of code to your theme’s
<?php add_filter('widget_text', 'do_shortcode') ?>
That’s it, now shortcodes will function normally when used in widgets.