Enable shortcodes in text widgets

This single line enables the shortcode functions in widgets. By default WordPress prints the [shortcode] tag and will not render it. do_shortcode is the template function to display a shortcode in a template file so we just need to add that to our widget_text filter.

/**
 * Snippet Name: Enable shortcodes in text widgets
 * Snippet URL: https://www.wpcustoms.net/snippets/enable-shortcodes-in-text-widgets/
 */
   add_filter('widget_text', 'do_shortcode', 11);
 

0 0 vote
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x