Help: Loading wp_editor in ajax

I’d like to post my solution since this thread is one of the first results on google and could be useful to many.

The point is that WP compiles a configuration object for each editor and it could be used only once in a webpage. The trick is to store the config object, manipulate it to manage your ajax editor and trigger tinymce.init()

Code for the webpage

<?php 
// create hidden fake editor
echo '
'; wp_editor('', 'editor_id'); echo '
'; ?>

Code for ajax response

<?php
$eid =  'NEW_editor_id';
wp_editor('', $eid);
?>


Simple, isn’t it? But has been a real nightmare to figure everything out without using absurd resources :smiley:

2 Likes