I created the WordPress editor using wp_editor function dynamically. While i click add more button i just cloned editor and append new editor using jquery. While i am cloning editor i just changing id distribution_0 to distribution_1 etc. Editor Properly creating, But editor tools of the dynamic editor is not working and producing js error like 'd' is not defined.

While go throw the wp_editor function codex. I saw notes about id should be used only lower case not any other like below. So i try to create 2 editor on same page directly using id with underscore (distribution__0) and it works fine. So is that statement falls in codex.Do you have any idea about this problem. kindly share with me.

Note that the ID that is passed to the wp_editor() function can only be comprised of lower-case letters. No underscores, no hyphens.> Anything else will cause the WYSIWYG editor to malfunction.

PHP code to create editor

   'media_buttons' => false,
   'textarea_rows' => 8,
   'textarea_name' => 'rw_toplist_description[]',
   'tabindex' => 4,
   'tinymce' => array(
   'theme_advanced_buttons1' => 'bold, italic, ul, min_size, max_size',


The problem is that the wp_editor() automatic load the scripts and this is not possible dynamic. You must enhance your plugin, code and add the scripts also dynamic or via ajax. WP include the scripts and styles via wp_enqueue_script() and this is not usable in a dynamic change of DOM, it was registered for better control.

Hints for find all script and styles.

The funciton wp_editor() is only a wrapper for the class class _WP_Editors and in this class do you find all method and inlcuded scripts. see in wp-includes/clas-wp-editor.php. See the methods editor_settings and enqueue_scripts for include js and styles.

  • do you have idea about what are the scripts i should reload. – Gowri Oct 29 '12 at 9:43
  • i have update the answer with a little bid more informations, there you can find the scripts and styles. – bueltge Oct 29 '12 at 10:06

I'm not sure about it but codex said "Once instantiated, the WYSIWYG editor cannot be moved around in the DOM. What this means in practical terms, is that you cannot put it in meta-boxes that can be dragged and placed elsewhere on the page."

Is your same javascript code working with other elements?

  • Yes working perfectly for other elements and editor works as well in meta box. so is this old statement. – Gowri Oct 29 '12 at 7:27
  • I'm not sure of this but it could be that the javascript variables are tied to the position of editor & when you try to clone or move it, it creates the error. Have you tried moving the meta box? – Mridul Aggarwal Oct 29 '12 at 7:41
  • I dragged and dropped in different position of the page that works fine, No issue with that. – Gowri Oct 29 '12 at 7:47
  • then probably the codex needs a correction – Mridul Aggarwal Oct 29 '12 at 8:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.