Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
WordPress: filter for the_content to remove excess tags around shortcodes
// get rid of junk <p> and <br> tags TinyMCE inserts around shortcodes
add_filter( 'the_content', function ( $content ) {
$array = [
'<p>[' => '[',
']</p>' => ']',
']<br />' => ']',
']<br>' => ']',
'<p>&nbsp;</p>' => '',
$content = strtr( $content, $array );
return $content;

This comment has been minimized.

Copy link
Owner Author

@donnamcmaster donnamcmaster commented May 1, 2019

see also for processing shortcodes outside the loop

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment