Skip to content

Instantly share code, notes, and snippets.

@zenman
Last active December 10, 2015 19:28
Show Gist options
  • Save zenman/4481016 to your computer and use it in GitHub Desktop.
Save zenman/4481016 to your computer and use it in GitHub Desktop.
Remove empty <p> tags from the_content() input
<?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