• Hey —

    I am trying to span images across the entire page, but because WordPress automatically inserts <p> before each line break, I am unable to do so.

    I have tried the following code which I found online:

    //filter the <p> tags from the images and iFrame
    function filter_ptags_on_images($content)
    {
    $content = preg_replace('/<p>\s*(<a .*>)?\s*(<img .* \/>)\s*(<\/a>)?\s*<\/p>/iU', '\1\2\3', $content);
    return preg_replace('/<p>\s*(<iframe .*>*.<\/iframe>)\s*<\/p>/iU', '\1', $content);
    }
    add_filter('the_content', 'filter_ptags_on_images');

    I am having no success with it though. Can someone help?

    Here is a link: https://moviemezzanine.com/full-width-image-layout-testing/

  • The topic ‘Disable/Remove p tags from auto generating around img’ is closed to new replies.