The Support Forums will be in read-only mode for a scheduled maintenance window on 01 September 2016 14:00 UTC - 20:00 UTC. More information.

Prevent WordPress from wrapping P tags around images (4 posts)

  1. Russell Heimlich
    Posted 9 years ago #

    Is there a plugin available to stop Worpess from wrapping my images in P tags? What is the PHP function that does this? I checked formatting.php in the 'WP-includes' folder and didn't see anything that looks familiar

  2. jabecker
    Posted 9 years ago #

    I would really like an answer to this, too. If I wanted p tags around my pictures, I'd put them there.

  3. Russell Heimlich
    Posted 9 years ago #

    This seems to be an elusive topic.

  4. tripleX2k7
    Posted 8 years ago #


    I realise you guys have probably either figured this out or given up on it but seeing as this shows up right at the top of google results for this problem then I thought I would say how to solve it.

    As it says in the topic at http://wordpress.org/support/topic/119014?replies=6 , wordpress knows that an img tag loose outside of p tags is invalid code (although it is valid if you have a containing div tag, as most themes do). WordPress detects that you haven't got a block level element around the image, and inserts p tags around it.

    To solve this, you can put a div tag around the image, for example:
    <div><img src='image.jpg' alt='an image' /></div>.
    This will cause WordPress to leave your image alone.

Topic Closed

This topic has been closed to new replies.

About this Topic