Remove P tags from images
-
How do you remove p tags from images?
With the Classic Text Editor, I was able to successful achieved that by this code.
function filter_ptags_on_images($content) { $content = preg_replace('/<p>\s*(<a .*>)?\s*(<img .* \/>)\s*(<\/a>)?\s*<\/p>/iU', '\1\2\3', $content); return preg_replace('/<p>\s*(<iframe .*>*.<\/iframe>)\s*<\/p>/iU', '\1', $content); } add_filter('acf_the_content', 'filter_ptags_on_images'); add_filter('the_content', 'filter_ptags_on_images');
But that doesn’t work with Gutenberg.
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Remove P tags from images’ is closed to new replies.