Home › Forums › General Issues › Removing Paragraph Tags › Reply To: Removing Paragraph Tags
Hi Elliot,
I have the same problems with <p>
tags appearing around images and around short code. If I start with the code in the wordpress visual or text editor it looks perfect (now that I have the following in my functions.php
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');
but in the custom fields I cannot seem to shake those extra paragraph tags. I use the html mode to remove them, update and they appear again.
I’m having similar trouble with shortcodes, but those don’t seem to be working in the wordpress editor either. Same problem happens in both places.
If you have any suggestions I’d really appreciate it.
Thanks,
Belinda
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.