Tips and Tricks

WordPress: Add TinyMCE to Textarea

WordPress: Add TinyMCE to Textarea: Whether you are adding custom fields for your theme or building a plugin and would like to convert a textarea to use WordPress HTML/Visual editor, you can easily achieve this using just 1 line of code.

WordPress: Add TinyMCE to Textarea

<?php wp_editor( $content, $editor_id, $settings = array() ); ?>

Example:

<?php wp_editor( $ewd_skills, 'ewd_skills_description' ); ?>

That above example will output a text area with the name ‘ewd_skills_description’ and the value of the custom field.

Where to add the above code:

Add the above code in functions.php file of your theme & save it.

Simple, isn’t it?

Do you know of any other ways to add TinyMCE to Textarea in WordPress? Feel free to suggest by commenting below.

4 Comments on WordPress: Add TinyMCE to Textarea

  1. 1

    Hello,
    But where should I add this code?
    Thank you

    • 2

      Good question. Simply add it in functions.php file of your theme, save it and that should do it. I have now updated the post with this info for future reference. Thanks for your input.

  2. 3

    Hi!!

    Thanks for the code but, I created an text area element with the add_settings_field and I am able to render, type and save text in it. How could I add the editor instead of the textarea?

    Thanks in advance.

    • 4

      Use the following code to render your TinyMCE Editor:

      If you want to populate the Editor with some value from database, retrieve such value first and then assign it to a custom variable and use it like so:

      In the above code, $custom_variable will hold the content retrieved from database.

      Try the above and let me know how that goes.

Leave a Reply to Luismin Cancel reply

*

*