Home › Forums › General Issues › Removing Paragraph Tags › Reply To: Removing Paragraph Tags
Hi @tebbott: Could you help me adapt this function? I want to apply it to a slightly different scenario, but my regex chops aren’t good enough:
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');
Function output:
<a href="#"><div>
</div></a>
Generated markup:
<a href="#"><div>
</div><p></a>
How can I strip out that annoying p tag?
I’m also using a version of the wpex_clean_shortcodes() function listed above. It works well for some scenarios but it’s not helpful here. Can your regex function help me?
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 Cookie Policy. If you continue to use this site, you consent to our use of cookies.