Remove Paragraph Tags From Images in WordPress

function filter_ptags_on_images($content){ return preg_replace('/ \s*(<a>)?\s*(<img alt="" />)\s*(<\/a>)?\s*<\/p>/iU', '\1\2\3', $content); } add_filter('the_content', 'filter_ptags_on_images');</a>

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.