Home › Forums › General Issues › Removing Paragraph Tags › Reply To: Removing Paragraph Tags
If anyone else is looking for a solution to removing <p> tags from around images, in the ACF WYSIWYG editor, just use the following code in your functions:
function filter_ptags_on_acf_images($acfcontent){
return preg_replace('/<p>\s*(<a .*>)?\s*(<img .* \/>)\s*(\/a>)?\s*<\/p>/iU', '\1\2\3', $acfcontent);
}
add_filter('acf_the_content', 'filter_ptags_on_images');
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.