Fix WordPress editor from deleting code

I’ve been pulling my hair out for the past hour on this… It seemed every time I got my post just right in the HTML editor then switched back to the Visual editor, all of my code between the shortcode tags we’re gone! I kept having to go back into my Revisions section and bring back prior auto-saves. Now, had I slowed down and noticed my code was gone in the first place maybe I could have saved the recovery step, but hey… I’m only human :P.

So as It turns out, I’m not using languages that TinyMCE (the default visual editor for WordPress) understands. After all, I’m trying to write blogs about SalesForce and other proprietary technologies, so anything not “XHTML” compliant will be stripped out of the TinyMCE editor.

TinyMCE has settings that are turned on by default to validate HTML. There is a real easy way to turn this setting off.

First off, you could muck through the core of WordPress without downlading/installing anything, but its just as easy to download a WordPress plugin that allows us to configure TinyMCE with little effort.

In your WordPress admin, click Add New under the Plugins menu and run a search for “Advanced TinyMCE Config” then install and activate the plugin.

Once you have it installed/activated follow these steps:

  1. navigate to Settings > TinyMCE Config
  2. Enter verify_html in the Option Name field
  3. Enter false in the Value field
Your settings should look like the following image:
TinyMCE Config – verify_html = false

 

 

 

 

 

 

 

Now you should be able to switch back and forth between the HTML and Visual editor without losing your code!

 

Sources:

http://www.tinymce.com/wiki.php/Configuration:verify_html

http://www.laptoptips.ca/projects/advanced-tinymce-configuration/

http://stackoverflow.com/questions/7058623/tinymce-completely-disable-validation

1 thought on “Fix WordPress editor from deleting code

Comments are closed.