I find myself more and more needing to use tables or divs inside my wordpress posts content. The problem I find with this is that one wrong backspace or newline, copy / paste has the possibility to throw off the whole code. Is there a best practices when it comes to adding html inside the content? Is there a way to make it so that the user cannot delete certain things inside posts content?

For Example: On one of my websites I have an accordion. Each accordion content is seperated by div class="accordContent" but when the user adds a new line inside the current accordContent div, it ends the current div and creates a new one with the same class that throws off the code.

  • 1
    I think it's best not to add html markup in post content, instead it should be added in template files. Commented Sep 9, 2013 at 13:56
  • I mean, by default the wordpress tinyMCE doesn't come with any kind of table setups. And usually, the user doesn't ever really need to add a new row or TD, but edit the content inside the table.
    – Howdy_McGee
    Commented Sep 9, 2013 at 14:00
  • 1
    1) create shortcodes that handle all tour needs 2) add buttons to tinyMCE that help to insert shortcodes.
    – gmazzap
    Commented Sep 9, 2013 at 14:04
  • 1
    For creating tables in content you can use these plugins wordpress.org/plugins/wp-tinymce-tables wordpress.org/plugins/ultimate-tinymce Commented Sep 9, 2013 at 14:05
  • @VinodDalvi right I know there is plugins for this sort of thing but for the most part I try to stay away from plugins. G.M. you're probably right that shortcodes are the best solution.
    – Howdy_McGee
    Commented Sep 9, 2013 at 14:09

1 Answer 1


Is there a way to make it so that the user cannot delete certain things inside posts content?

You need...

  1. A shortcode that will generate the content. This will let your users provide input but the markup can be rigidly controlled.
  2. Or a custom meta field. The markup around this can also be rigidly controlled, but to a lesser extent, or in a different way.
  3. Or you need to write the markup into the templates.

I can't tell you exactly which you need. I'm not sure. I think the shortcode, or a group of shortcodes, might do what you need.

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.