Support

Account

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