wordpress snippets last updated   : July 14, 2014
we now have 634 snippets

Remove p tag from around images in the_content

wordpress snippet

Adding this snippet to the functions.php of your wordpress theme will remove the HTML p tag from around images in the_content.

snippet :  PHPcopy
function filter_ptags_on_images($content){
    return preg_replace('/<p>\s*(<a .*>)?\s*(<img .* \/>)\s*(<\/a>)?\s*<\/p>/iU', '\1\2\3', $content);
}
add_filter('the_content', 'filter_ptags_on_images');
source →
jqsnipp.com | we just launched jquery snippets website