Last active
March 12, 2021 17:55
-
-
Save rossberenson/9170f5d1c2feb6d0b839f9ad377823e4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Removes empty paragraph tags from shortcodes in WordPress. | |
* | |
* https://thomasgriffin.com/how-to-remove-empty-paragraph-tags-from-shortcodes-in-wordpress/ | |
*/ | |
function remove_empty_paragraph_tags_from_shortcodes_wordpress( $content ) { | |
$to_fix = array( | |
'<p>[' => '[', | |
']</p>' => ']', | |
']<br />' => ']' | |
); | |
return strtr( $content, $to_fix ); | |
} | |
add_filter( 'the_content', 'remove_empty_paragraph_tags_from_shortcodes_wordpress' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment