Skip to content

Instantly share code, notes, and snippets.

@yumyo
Forked from ninnypants/remove-empty-p.php
Created November 16, 2012 17:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yumyo/4089059 to your computer and use it in GitHub Desktop.
Save yumyo/4089059 to your computer and use it in GitHub Desktop.
Remove empty p tags from WordPress posts
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);
}
@yumyo
Copy link
Author

yumyo commented Nov 16, 2012

need to test if add_filter('the_content', 'remove_empty_p',99999); works better

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment