Few days before, I developed a WordPress custom widget as per requirement and in that I was using textbox and textarea for inputting data. I was using HTML tags and Shortcodes in custom widget but Problem was that short-codes rendering out as text.
in my functions.php file I have added the add_filters for short-codes to display in text widgets.
1 | add_filter(‘widget_text’, ‘do_shortcode’); |
But it was not working. Then I googled on it and find it out that ‘widget_text’ filter work for the standard text widget. I have tried just about everything and its driving me crazy.
But at last I got the solution that If I will directly use do_shortcode function on the textarea value then it will execute all the shortcodes exists in the textarea. So simple use below given code to execute Shortcodes in custom widget for WordPress.
1 | echo do_shortcode($text_message); |