• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

WP SITES

2762

Original Genesis Tutorials & 6000+ Guaranteed Code

Snippets

  • Premium Access
  • Log in

Enable Use of Shortcodes Anywhere in WordPress

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.

Subscribe for new Tutorials

Reader Interactions

Comments

  1. Angela says

    August 26, 2014 at 7:21 pm

    Thanks so much for posting! Worked like a charm – and saved me a TON of time. I really appreciate your tutorial library!

    Log in to Reply
    • Brad Dalton says

      August 27, 2014 at 9:03 am

      You’re welcome Angela.

      Log in to Reply
  2. Maggie Wall says

    February 4, 2013 at 12:00 pm

    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?

    Log in to Reply
    • Brad Dalton says

      February 4, 2013 at 12:21 pm

      Hi Maggie. Some probably do whereas some want to keep the files as small as possible.

      Log in to Reply

Leave a Reply Cancel reply

You must be logged in to post a comment.

Primary Sidebar

Code written by Brad Dalton specialist for WooCommerce & WordPress theme customization. Read More…

Advertise · WPEngine · Genesis · Log in

  • Access Problems
  • Account Details
  • Consulting