Created
October 18, 2019 06:57
-
-
Save TeemuSuoranta/16accb52a24f1f4dd0d22df701047d76 to your computer and use it in GitHub Desktop.
Remove empty paragraphs from post_content
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 paragraphs | |
* | |
* @param string $content the HTML markup of content | |
* | |
* @return string the HTML markup of content | |
*/ | |
add_filter('the_content', function ($content) { | |
if (!is_admin()) { | |
$content = str_replace('<p></p>', '', $content); | |
$content = str_replace('<p> </p>', '', $content); | |
} | |
return $content; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment