How can I make my custom shortcode work in a Custom HTML Widget?

I was able to make it work by adding these two lines to my theme’s functions.php file:

add_filter( 'widget_text', 'shortcode_unautop');
add_filter( 'widget_text', 'do_shortcode');

The Custom HTML Widget now correctly executes the shortcode function and outputs the result.

Leave a Comment