Created
February 10, 2013 22:56
-
-
Save aosteraas/4751417 to your computer and use it in GitHub Desktop.
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 p tags from images | |
function remove_img_p_tag($content){ | |
return preg_replace('/<p>\s*(<a .*>)?\s*(<img .* \/>)\s*(\/a>)?\s*<\/p>/iU', '\1\2\3', $content); | |
} | |
add_filter('the_content', 'remove_img_p_tag'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment