Last active
December 10, 2015 19:28
-
-
Save zenman/4481016 to your computer and use it in GitHub Desktop.
Remove empty <p> tags from the_content() input
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
<?php | |
/* | |
* Remove empty <p> tags from the_content() input | |
* | |
*/ | |
add_filter('the_content', 'remove_empty_p', 20, 1); | |
function remove_empty_p($content){ | |
$content = force_balance_tags($content); | |
return preg_replace('#<p>\s*+(<br\s*/*>)?\s*</p>#i', '', $content); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment