Home » Functions » wp_editor

The WordPress function wp_editor() is a powerful tool that allows you to add a WYSIWYG (What You See Is What You Get) editor to any page or post on your website. It’s particularly useful if you’re creating custom post types, where you want to provide users with a user-friendly interface for editing content.

When you call the wp_editor() function, it generates an editor in the DOM with the specified settings. You can choose to enable or disable certain features, such as the ability to add media, links, or code snippets. You can also set the default text color, font, and format. The function also supports the TinyMCE editor plugin, which provides additional formatting options and buttons.

One of the most common use cases for wp_editor() is to allow users to edit content in a front-end submission form. For example, if you have a membership site that allows users to submit articles, you could use wp_editor() to provide them with a simple and intuitive interface for creating and editing their content.

Here’s an example usage code for wp_editor():

$settings = array(
    'textarea_name' => 'mytextarea',
    'media_buttons' => true,
    'tinymce' => array(
        'toolbar1' => 'bold italic | bullist numlist | link',
        'toolbar2' => 'blockquote | code',
        'toolbar3' => '',
        'toolbar4' => '',

wp_editor('', 'myeditor', $settings);

In this example, we’re creating an editor with the ID ‘myeditor’ and the name ‘mytextarea’. We’ve enabled the media buttons and added some custom formatting options to the TinyMCE toolbar.

Overall, the wp_editor() function is a flexible and powerful tool that can make your life as a developer much easier. Whether you’re building a custom post type or developing a front-end submission form, it’s definitely worth checking out.

Learn More on WordPress.org

Register an account to save your snippets or go Pro to get more features.