Skip to content

Instantly share code, notes, and snippets.

View alexmustin's full-sized avatar

Alex Mustin alexmustin

View GitHub Profile
@alexmustin
alexmustin / functions.php
Created July 17, 2020 21:35 — forked from sirchrispy/functions.php
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