In my wordpress theme, I have a custom options panel with textareas that utilize the tinymce script included with wordpress.

This was working fine until I upgraded to the latest version of wordpress (3.2). Now the editor still works, however it is removing all paragraph and line-break tags once I save my code. While putting my text into the editor, it looks great and shows all line breaks in the preview, but once I save it those are all gone. Other tags (b, img, a) seem to be working fine.

Now this may be an issue with wordpress, but on the same hand the wordpress upgrade also included the newest and latest version of Tinymce, so that may be causing the issue.

When I disable the Tinymce editor and use standard textareas, all the tags and line breaks get saved no problem.

EDIT: Got it working. Needed to wrap my output values in wpautop() before saving. So now my value is wpautop($output[$option_array['id']]);

Here is the code I am using to initiate the Tinymce editor:

wp_tiny_mce( false , // true makes the editor "teeny"
        'theme' => 'advanced',
        'skin' => 'default',
        'theme_advanced_resizing' => 'false',
        'theme_advanced_path' => 'false',
        'theme_advanced_buttons2' => '',
        'theme_advanced_buttons1' => 'code,bold,italic,underline,|,justifyleft,justifycenter,justifyright,forecolor,fontsizeselect,link,unlink,image',
         'width' => '650px',
         'media_strict' => 'false',
'valid_elements' => '*',
'extended_valid_elements' => '*',


4 Answers 4


You may need to use one of the following configuration parameters:

// Don't remove line breaks
'remove_linebreaks' => false; 
// Convert newline characters to BR tags
'convert_newlines_to_brs' => true; 

WordPress passes an $init argument array to TinyMCE that sets the opposite value for each of these parameters.

I assume you can pass them directly in your wp_tiny_mce() argument array, but I've not tried; I pass them as array parameters for a custom filter of the TinyMCE $init array.

  • I added it, but it does not seem to make a difference in the actual output of the stored text. Once I add those parameters to my array, this is what I see in the source code that its generating: pastie.org/2178029 Is it not setting those options properly?
    – Levi
    Commented Jul 7, 2011 at 15:08
  • 1
    Nevermind, I found the answer. wordpress.stackexchange.com/questions/15394/… Thanks for helping though. I appreciate it
    – Levi
    Commented Jul 7, 2011 at 15:23
  • Oh, that's great! :) Commented Jul 7, 2011 at 15:44

I don't load the full editor but controlling which TinyMCE plugins are loaded does the trick. For example, for my purposes I only need the paste plugin so I added:

'plugins' => 'paste'

to the array.

I do not know for sure which plugin causes the p and br tags top be removed, but thru some trial and error or digging thru the code of the plugins you can find which one not to include. Here are the plugins loaded by default:

'inlinepopups', 'spellchecker', 'tabfocus', 'paste', 'media', 'wordpress', 'wpfullscreen', 'wpeditimage', 'wpgallery', 'wplink', 'wpdialogs'

When displaying your values on the frontend, run it through the filter: 'the_content'. There is also a function that must be called prior to prepare the content in the text input.


Maybe this can help:


  • 1
    Read the entire question. He referenced wpautop in the question itself. Linking back to the Codex is not an answer.
    – EAMann
    Commented Nov 18, 2011 at 16:55

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.