• I’ve been trying to remove the <p> tags from an image from this website I’m working on. The white space between the menu and the content is where the image should be. If I view the source and remove the <p> tags myself, the image displays normally.

    http://hoffmastergroupinc.tushausweb.com/

    I’m using a function (in functions.php) to remove <p> tags surrounding an image, but it doesn’t appear to be working.

    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');

    Am I doing it wrong? Help on this would be much appreciated.

The topic ‘Removing tags in Functions.php?’ is closed to new replies.