Simply pasting a shortcode into any of your widget areas generally won’t work.
To enable the use of shortcodes in any text widget area, on any theme, simply add this code to your child themes functions.php file.
add_filter( 'widget_text', 'shortcode_unautop');
add_filter( 'widget_text', 'do_shortcode');
This enables short codes in excerpts:
add_filter( 'the_excerpt', 'shortcode_unautop');
add_filter( 'the_excerpt', 'do_shortcode');
This enables use of short codes in your description field for archive pages
add_filter( 'term_description', 'shortcode_unautop');
add_filter( 'term_description', 'do_shortcode' );
This enables use of short codes in comments:
add_filter( 'comment_text', 'shortcode_unautop');
add_filter( 'comment_text', 'do_shortcode' );
Now all you need to do is paste your shortcodes and they will work.
Thanks so much for posting! Worked like a charm – and saved me a TON of time. I really appreciate your tutorial library!
You’re welcome Angela.
So Brad,
If all it takes is one line of code in the child theme php area, why don’t child themes just put the line in so that way people will be able to do shortcode widgets as a default / automatic thing?
Hi Maggie. Some probably do whereas some want to keep the files as small as possible.