wp_editor( $default_content, $editor_id,array('textarea_name' => $option_name,'media_buttons' => false,'editor_height' => 350,'teeny' => true)  );
   submit_button('Save', 'primary');   

I want to create a mail template where admin can change content and put shortcode where he wants.

created a form and wrote the code above but when I click on save it not save the HTML formatted content.

please help any one

  • the first step is to create a form with a textarea. and when saving the text of this textarea works, just add the call to wp_editor. – mmm Jan 4 '18 at 11:02
  • @mmm can you send me code how to implement it – Vivek Tamrakar Jan 4 '18 at 11:03
  • You have not explain how you want to use this. Edit your question to add more details. – mmm Jan 4 '18 at 11:12
  • I want to design dynamic email template in admin where he can change content and design it accordingly – Vivek Tamrakar Jan 4 '18 at 11:18
  • You need to register the settings field and such. You can read up on the WordPress Settings API – Cedon Jan 4 '18 at 21:23
echo '<form action="" class="booked-settings-form" method="post">';
$default_content='<p>Mail formate</p>';
$editor_id = 'customerCleanerMail';
wp_editor( $default_content, $editor_id,array('textarea_name' => $option_name,'media_buttons' => false,'editor_height' => 350,'teeny' => true)  );
submit_button('Save', 'primary');   echo '</form>';
if(isset($_POST['customerCleanerMail'])  ){
      $fff=update_option('customerCleanerMail', $var2);

In form section i used wp_editor with his options, wp_editor work like html editor but when you store these data it not storing html data. so we found solution how to store html data wpautop() and htmlentities() both two functions help to store html formated data

|improve this answer|||||

Very simple

if (isset($_POST[$editor_id])){ update_option('name_option_you_want', $editor_id); }

|improve this answer|||||
  • 1
    Please edit your answer, and add an explanation: why could that solve the problem? – fuxia Jan 6 '18 at 19:29

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.