How to dynamically generate wordpress editor on frontend?

I want to initialize the wordpress editor dynamically on frontend. I have tried to include the following scripts:

wp_enqueue_script('editor');
wp_enqueue_script('media-upload');
wp_enqueue_script('thickbox');

Then to init the editor like this:

tinymce.init({
  mode : 'specific_textareas',
  editor_selector :'tinymce'
});

But it does not work. Any ideas?

Topic wp-editor editor tinymce wysiwyg Wordpress

Category Web


You are in luck. There is a Wordpress internal function for that. It's the wp_editor function.

The function does all the work for you. It enqueues the right scripts and style-sheets. Just pass the configuration you want.

wp_editor('Enter your text here', 'editor_id_here') 

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.