Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

TinyMCE Problem on Custom Options Page WordPress


I have created a Custom Options Page for my theme. I've also integrated the TinyMCE Editor for all my textareas.

I've added this code...

function ShowTinyMCE() {
wp_enqueue_script( 'common' );
wp_enqueue_script( 'jquery-color' );
if (function_exists('add_thickbox')) add_thickbox();
if (function_exists('wp_tiny_mce')) wp_tiny_mce();

And I've used this... to display the TextArea

<div id="poststuff">
the_editor("$content", "content", "", true);

Here's my problem...

When the line.. if (function_exists('wp_tiny_mce')) wp_tiny_mce(); is added all my P and BR tags are gone from the editor. They do not show in the HTML tab when viewed and are stripped when saved.

So I need to know what to add to get them back or how to fix this. I actually need the P tags and BR as well.

I've tried using....

this by itself didn't work.

I've tried...


still no luck.

any ideas of why when adding wp_tiny_mce that it actually strips <p> and <br> the plugin.

Again, this is NOT on saving. They just DO NOT appear.

It seems this happens when switching from Visual to HTML.

Any help would be great.

Answers (3)


Denzel Chia answers:


Tinymce editor will strip all p and br tags when saved into WordPress Database, which is the same for the normal post content.

in order to get back the p and br tags, use wpautop() for the variable before assigning the retrieved option value back to text area or used on theme template.

example code

$content = get_option('value_saved');
$content = wpautop($content);
//do what you want with $content

Please tell me if you need me to code directly into your theme options.


Denzel Chia comments:


You can email me a zip copy of your theme to [email protected], if you want me to fix your codes directly. I had done it before, please see this thread
I am sure I can do it again.


Denzel Chia comments:


I had send you the modified sidebaroptin.php in my reply email to you.

These are the modified codes in it to process your saved tinymce option data.

<div id="sidebar2">
$content = get_option('wtf_optinbox');
$content = do_shortcode($content);
$content = wpautop($content);
echo $content;

There is nothing wrong with your tinymce editor.
It is the normal behavior for tinymce editor, not to show p tags in it.
You need to process the retrieve option data with at least wpautop, so as to get the correct formatting.

Please see the attached screenshot for fixed paragraph output formating in your sidebar.

There is additional information in my reply email to you.