Support » Fixing WordPress » Prevent WordPress from wrapping P tags around images

  • 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

Viewing 3 replies - 1 through 3 (of 3 total)
  • I would really like an answer to this, too. If I wanted p tags around my pictures, I’d put them there.

    This seems to be an elusive topic.


    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 , 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.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Prevent WordPress from wrapping P tags around images’ is closed to new replies.