How to Use Shortcodes in WordPress Text Widgets

How to Use Shortcodes in WordPress Text Widgets

Quite awhile ago I shared a tip on using shortcodes outside of the post editor. Here’s another equally handy snippet for enabling shortcode use within WordPress text widgets.

Add this to your functions.php file:
{code type=php}
add_filter( ‘widget_text’, ‘shortcode_unautop’);
add_filter( ‘widget_text’, ‘do_shortcode’);

FREE EBOOK
Your step-by-step roadmap to a profitable web dev business. From landing more clients to scaling like crazy.

By downloading this ebook I consent to occasionally receive emails from WPMU DEV.
We keep your email 100% private and do not spam.

FREE EBOOK
Plan, build, and launch your next WP site without a hitch. Our checklist makes the process easy and repeatable.

By downloading this ebook I consent to occasionally receive emails from WPMU DEV.
We keep your email 100% private and do not spam.

Source: using shortcodes everywhere

Now you’ll be able to use shortcodes within text widgets, just as you would within the post editor. Follow Stephanie Leary’s tutorial to add shortcodes virtually anywhere you want within WordPress.

Tags: