WordPress: filter for the_content to remove excess tags around shortcodes
<?php | |
// get rid of junk <p> and <br> tags TinyMCE inserts around shortcodes | |
add_filter( 'the_content', function ( $content ) { | |
$array = [ | |
'<p>[' => '[', | |
']</p>' => ']', | |
']<br />' => ']', | |
']<br>' => ']', | |
'<p> </p>' => '', | |
]; | |
$content = strtr( $content, $array ); | |
return $content; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This comment has been minimized.
see also https://gist.github.com/donnamcmaster/b634ac4a7ebec6b3814b75d243ed23fd for processing shortcodes outside the loop