Support » Fixing WordPress » <div> tags replaced by <p> How do I make it stick?

  • My <div> tags in the code window keep getting replaced with <p> tags after the page is saved. How do I stop this from happening?


Viewing 9 replies - 1 through 9 (of 9 total)
  • Since the DIV tag is considered more as layout markup the developers convert it to a paragraph to be more writer / semantic friendly. For most people this may be a good idea, but if you understand what you are doing DIVs can be useful.

    It’s one of the reasons I wrote WP Super Edit. It’s a plugin specifically to manipulate the Visual Editor. You can find it at

    I don’t know if this is truely your problem since you mentioned that you were saving from code view. If the plugin doesn’t work for you, you might want to provide your WordPress version.

    Thank you very much, ev3rywh3re. I’ll look into this plugin.

    I am having the same problem. I want to post divs codes among with text, but the editor keeps converting them to P’s.

    Is there an easy way to just make my WordPress simply stop doing that with divs?

    my version is 2.3.1 (latest).

    bump. please help ^^

    just to confirm: I want to cancel this option, I don’t want wordpress converting my “divs” to “ps”, something easy for a newbie programmer.

    Found an answer for this, and thought I’d share it here.

    Edit this file:


    Line 26 reads as follows:

    $valid_elements =

    Remove the first portion, like so:
    $valid_elements =

    After you’ve done that, be sure to reset your browser cache.

    aarondiers, you are awesome.
    Thanks for that. Did it, it worked, You Rock.

    Actually, all you have to do is make up a bogus CSS class (call it “this_does_nothing” or something like that) and add it to any divs that you want to keep. Since WP thinks that the markup has styling applied, it will leave it alone.

    Oh, Nice! Did WP stop tampering with div tags?
    I do believe so!
    Now I can stop pulling what’s left of my hair out.
    I’ve been using super edit for just that reason.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘<div> tags replaced by <p> How do I make it stick?’ is closed to new replies.