In a perfect world, WordPress would take what I enter into the HTML editor and write it verbatim into the post/page document received by the browser. Disabling wpautop has already helped me slightly to this end. Alas..

Setup: I write some HTML into the editor and click UPDATE. My post/page is formatted correctly, but the contents of my editor have changed: p and br tags are gone, replaced respectively with actual empty lines and line breaks. When I view source, the contents of the editor textarea are what I originally typed, but its as if p and br tags are actually being rendered in the textarea.

The problem is that when I click UPDATE again (without changing anything), the post/page is formatted incorrectly, because said tags are lost.

How can I get my HTML editor contents not to be automatically mangled? I do not ever switch over to the visual editor. Just scanning through wp-includes/formatting.php, the function format_to_edit seems promising, but unsure how to proceed.


  1. Enter <p>Hello</p> in HTML editor for new post
  2. Click PUBLISH, published post is formatted correctly
  3. Contents of editor changed after the PUBLISH refresh to Hello (p tags gone)
  4. Click UPDATE, post is formatted incorrectly due to lack of p tags


After looking at some of the comments/answers and doing some testing, this does look like a hackery side-effect. I can't repro in a fresh install of Roots. Here are the details of my install:

  1. Customized Roots theme, no hackery.
  2. Plugins: Akismet, Advanced Custom Fields, Custom Post Type UI, Google Analytics for WP
  • 2
    Looks like a side-effect of some hackery stuff.
    – Ashfame
    Commented May 29, 2012 at 17:43
  • Why do you need the markup to begin with?
    – Tom J Nowell
    Commented May 30, 2012 at 11:23
  • @TomJNowell so that the post is formatted/spaced correctly.. and so that my site outputs clean semantic markup.
    – calebds
    Commented May 30, 2012 at 14:13
  • 1
    Then you've got it completely wrong. Adding p tags for spacing purposes is not semantic at all, the same with br tags ( which I advise against ). Spacing is a stylesheet thing not a html thing.
    – Tom J Nowell
    Commented May 30, 2012 at 14:51
  • 1
    What you're trying to do is bad practice, it's wrong, use css instead. ( and avoid <br> tags where possible )
    – Tom J Nowell
    Commented May 30, 2012 at 14:52

2 Answers 2


It may help you to render content in your theme directly without the_content filter, although you would loose thigns like oembeds etc e.g.:

echo $post->post_content;

However this sounds like a symptom of a hack. If you have something complex like an embed then you should be using either oembed ( e.g. youtube, don't be pasting the raw embed stuff ) or using a shortcode. Else there's very, very few reasons to keep the html markup for things like p and br tags for ordinary content, and if you're using div containers and other layout elements then you're doing it wrong

  • This doesn't solve the problem of my editor contents being changed. I'm happy with what WP is outputting in my theme.. it's just that the original markup I write in the editor is lost after I UPDATE again, so I have to paste in entirely fresh markup every time I make a change.
    – calebds
    Commented May 29, 2012 at 16:57

I had this issue once and it was caused, as Ashfame comments and Tom J Novell mentions, by a double hackery stuff.

My functions.php was removing some the_content filters and a plugin (don't remember which) was doing the same.

There are some basic troubleshooting steps that you may take. They are outlined in this post by the always cognoscenti Ipstenu. I'll reproduce the steps bellow, but the article is worthwhile reading in full.

  • flushing any caching plugins you might be running, as well as server and/or browser caches.

  • deactivating all plugins (yes, all) to see if this resolves the problem. If this works, re-activate the plugins one by one until you find the problematic plugin(s). If you can't get into your admin dashboard, try resetting the plugins folder by FTP or PhpMyAdmin. Sometimes, an apparently inactive plugin can still cause problems. Also remember to deactivate any plugins in the mu-plugins folder. The easiest way is to rename that folder to mu-plugins-old

  • switching to the Twenty Eleven theme to rule out any theme-specific problems. If you can't log in to change themes, you can remove the theme folders via FTP so the only one is twentyeleven. That will force your site to use it.

  • manually upgrading. When all else fails, download a fresh copy of the latest.zip file of 3.3 (top right on this page) to your computer, and use that to copy up. You may need to delete the wp-admin and wp-includes folders on your server. Read the Manual Update directions first!

If it is complicated for you to practically shut down a live site for doing this, two options:


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.