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

How To Add a TinyMCE Editor To an Options Page? WordPress



I would like to know how to add a TinyMCE editor to this options page:

I've followed this tutorial,
and everything is showing up correctly, but I don't know how to save the data entered to the database.

When I click "Save Changes" nothing gets saved.

It appears the linked tutorial is incomplete because it doesn't contain the information needed to make the TinyMCE editor save the data.

This is the code I'm using now in my functions.php for the case part:

case 'editor':
<div class="rm_input rm_textarea">
<label for="<?php echo $value['id']; ?>"><?php echo $value['name']; ?></label>
<div class="editor_holder"><?php the_editor($content_to_load);?></div>

Then for the array part:

array( "name" => "Description Box Contents",
"desc" => "Description copy",
"id" => $shortname."_editor_content",
"type" => "editor",
"std" => ""),

The function to create TinyMCE:

function ShowTinyMCE() {
// conditions here
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 calling the contents submitted through the editor in the template:

<?php echo get_option('nt_editor_content'); ?>

Your help is much appreciated.

Answers (6)


Denzel Chia answers:


You said you follow this tutorial for creating options page.
Did you include step 5? Step 5 updates the input into WordPress options table, using update_option function.

If you include step 5 then something must be wrong with the name attribute of the input field, it must be the same as post and updated into database.

Please paste all your codes here so that people can help you.

Get the option page correct first, make sure you and able to update and get option before adding tiny mce editor.


Denzel Chia comments:

You used get_option('nt_editor_content'), make sure in your step 5 you use update_option('nt_editor_content','your_input_name') to save data in wordpress.
Whereby your_input_name is the name attribute of your textarea. This is basic HTML.


Baki Goxhaj answers:

Try to convert this into a real textarea:

<div class="editor_holder"><?php the_editor($content_to_load);?></div>

Edwin comments:

Could you post a code example of how to do this?

Baki Goxhaj comments:

This simple:

<textarea class="editor_holder"><?php the_editor($content_to_load);?></textarea>

Edwin comments:

Hi Baki,

Unfortunately it didn't work, it basically killed the TinyMCE editor entirely.