This might be a stupid question, and maybe I’ve missed some best practices thing, but I’ve been having this problem with clients using sites on WordPress. Let’s say we have a fairly complex page that requires some good amount of HTML code inside the page itself. We put it up and it looks great. Now, month later client wants to edit couple words there, goes in and edits them in Visual Mode, and of course all markup that we did is now screwed up, so stuff is all over the place.
What are the approaches we can use to handle cases like that?
One thing you could do is create page templates for complex pages and simply add the content through the editor, leave as little mark-up as possible in the editor.
Another thing that might help is using the editor style (activated with
add_editor_style()
infunctions.php
) and defined ineditor-style.css
so the client has a better sense of what’s going to be displayed (if you mimic your theme pretty closely) right in the editor.Add custom fields with descriptive names for information which needs to be displayed in a certain way, in a certain place, rather than lumping it in the main content. The simple fields plugin simplifies this a lot, permits repeatable fields and file uploads. It gives flexibility while avoiding letting your client shoot himself in the foot so easily. Or you could make your own metaboxes,etc.
One obvious, but probably not satisfactory, solution would be to disable the visual editor for these pages.
To be able to really keep editors off sensitive markup, you should create a page template, like Cronco suggests. If you find that you have several editable parts, you can store them as custom fields.
Unfortunately, editing these custom fields through the default admin interface would be as far from WYSIWYG as you can get. You can make it better by using Front-end Editor, which allows you to edit custom fields inline.
You should definitely use a plugin I wrote instead of going through the hoops and limitations recommended in the other answers.
I already answered this similar question: https://wordpress.stackexchange.com/a/48832/10127
Here’s a direct link to the plugin:
http://wordpress.org/extend/plugins/preserved-html-editor-markup/
Switching between visual and html tabs will not drastically alter your markup, and end users can still use the visual tab, making modifications to the content, without changing the general structure of the html. Be sure to read the entire readme file before deciding if this plugin is for you, but it definitely sounds like what you’re looking for.