Need to remove automatic p tags around images
-
Hi!
I’m adding an image to the content, however it keeps getting wrapped in p tags so I can’t float it.
I’m using this code in an attempt to get rid of them:
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');
I don’t think the_content works in this case because you are using a custom field? Is there a way around this?
Thanks!
The page I need help with: [log in to see the link]
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Need to remove automatic p tags around images’ is closed to new replies.