Skip to content

Instantly share code, notes, and snippets.

@sirchrispy
Created March 25, 2015 21:04
Show Gist options
  • Save sirchrispy/63e700470e665acf04dc to your computer and use it in GitHub Desktop.
Save sirchrispy/63e700470e665acf04dc to your computer and use it in GitHub Desktop.
WP: Allow shortcodes everywhere
//* Shortcode optimization
add_filter( 'the_content', 'do_shortcode' ); // Allow shortcodes inside of shortcodes
add_filter( 'comment_text', 'do_shortcode' ); // Allow shortcodes in comments
add_filter( 'comment_text', 'shortcode_unautop' ); // Prevent comment shortcodes from wrapping in <p>...</p> tags
add_filter( 'the_excerpt', 'do_shortcode' ); // Allow shortcodes in excerpts
add_filter( 'the_excerpt', 'shortcode_unautop' ); // Prevent excerpt shortcodes from wrapping in <p>...</p> tags
add_filter( 'widget_text', 'do_shortcode' ); // Allow shortcodes in widgets
add_filter( 'widget_text', 'shortcode_unautop' ); // Prevent shortcodes in widgets from wrapping in <p>...</p> tags
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment