I'm creating a custom options page and I have a textarea that I've turned into a TinyMCE editor using wp_editor.

TinyMCE displays correctly, however it breaks when I include square brackets in the $id. Here's the code I'm using for the add_settings_field function callback:

function px_wp_editor($args){
        $options    = get_option('theme_options');  
        $value      = $options['px_wp_editor'];
        $id         = 'theme_options[px_wp_editor]';

         extract( $args );
         $class = (!empty($class))?$class:'';

         $settings = array(
            'textarea_rows'     => 12,
            'textarea_name'     => $id, 
            'editor_class'      => $class,
            'media_buttons'     => true,
            'tinymce'           => true
         wp_editor($value, $id, $settings );            

If I removed the square brackets from the $id value then it displays fine. However, because of the way I'm retrieving the values using get_option, I need to call "textarea_name" as it currently is, with square brackets.

The first pic below is how it looks when using square brackets for the name (full icons don't display correctly and there are no Visual/Text buttons.

The second pic is how it should display.

Here's a screenshot of how it looks when using square brackets for the name Here's how it should look

2 Answers 2


You cannot put square brackets as editor id. but you can change textarea name by.

wp_editor('','px_wp_editor',array('textarea_name' => 'theme_options[px_wp_editor]'));

the important part is, "id" and "textarea_name" are different.

  • Please explain why this answer is helpful.
    – kaiser
    Commented Mar 11, 2015 at 13:49
  • 2
    the important part is "id" and "textarea_name" are different. thats all. thats all. Commented Mar 16, 2015 at 11:56
  • Then please, tell that in your answer, and not in the comments.
    – kaiser
    Commented Mar 16, 2015 at 13:37

I'm not able to test this right now, but try this:

$id = htmlentities('theme_options[px_wp_editor]');
  • Doesn't work :(
    – pixelkicks
    Commented Jul 30, 2014 at 16:01
  • 1
    Sad Christmas. :( I'll try to test this myself and work out why this doesn't work when I get a moment.
    – Jack Lenox
    Commented Jul 30, 2014 at 16:14

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.