Skip to content

Instantly share code, notes, and snippets.

@alexmustin
Forked from sirchrispy/functions.php
Created July 17, 2020 21:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexmustin/ebc5a1621c5636ade611d916c659997a to your computer and use it in GitHub Desktop.
Save alexmustin/ebc5a1621c5636ade611d916c659997a 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