Created
April 6, 2012 16:33
-
-
Save ninnypants/2321174 to your computer and use it in GitHub Desktop.
Clean up empty tags in the_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 | |
add_filter('the_content', 'remove_empty_p', 20, 1); | |
function remove_empty_p($content){ | |
// clean up p tags around divs | |
$content = str_replace(array('<p><div', '</div></p>'), array('<div', '</div>'), $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