Attention Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

Function Reference/wp editor


This function renders an editor in a page in the typical fashion used in Posts and Pages.


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


(string) (required) Initial content for the editor.
Default: None
(string) (required) HTML id attribute value for the textarea and TinyMCE. (may only contain lowercase letters and underscores...hyphens will cause editor to not display properly)
Default: None
(array) (optional) An array of arguments.
Default: array()


(boolean) (optional) Whether to use wpautop for adding in paragraphs. Note that the paragraphs are added automatically when wpautop is false.
Default: true
(boolean) (optional) Whether to display media insert/upload buttons
Default: true
(string) (optional) The name assigned to the generated textarea and passed parameter when the form is submitted. (may include [] to pass data as array)
Default: $editor_id
(integer) (optional) The number of rows to display for the textarea
Default: get_option('default_post_edit_rows', 10)
(integer) (optional) The tabindex value used for the form field
Default: None
(string) (optional) Additional CSS styling applied for both visual and HTML editors buttons, needs to include <style> tags, can use "scoped"
Default: None
(string) (optional) Any extra CSS Classes to append to the Editor textarea
Default: Empty string
(integer) (optional) The height to set the editor in pixels. If set, will be used instead of textarea_rows. (since WordPress 3.5)
Default: None
(boolean) (optional) Whether to output the minimal editor configuration used in PressThis
Default: false
(boolean) (optional) Whether to replace the default fullscreen editor with DFW (needs specific DOM elements and CSS)
Default: false
(array) (optional) Load TinyMCE, can be used to pass settings directly to TinyMCE using an array
Default: true
(array) (optional) Load Quicktags, can be used to pass settings directly to Quicktags using an array. Set to false to remove your editor's Visual and Text tabs.
Default: true
(boolean) (optional) Enable Drag & Drop Upload Support (since WordPress 3.9)
Default: false

Return Values

This function does not return a value.


Display an empty editor using the default settings:


$content = '';
$editor_id = 'mycustomeditor';

wp_editor( $content, $editor_id );


Fill an editor with the content for a particular post:


$post_id = 51;
$post = get_post( $post_id, OBJECT, 'edit' );

$content = $post->post_content;
$editor_id = 'editpost';

wp_editor( $content, $editor_id );


We can also pass an array of one or more settings if the defaults don't suit our needs. For example, if we wanted to hide the insert media buttons, we would do this:


$settings = array( 'media_buttons' => false );

wp_editor( $content, $editor_id, $settings );


We can also modify the default quicktags using a custom list of buttons including a custom list of quicktags.

An exhaustive list of the available default quicktags can be found at [1](https://codex.wordpress.org/Quicktags_API#Default_Quicktags). Use the Quicktag's ID in the list you pass as the quicktags setting.


$settings = array( 
	'quicktags' => array( 'buttons' => 'strong,em,del,ul,ol,li,close' ), // note that spaces in this list seem to cause an issue

wp_editor( $content, $editor_id, $settings );



  • Note that the ID that is passed to the wp_editor() function can only be composed of lower-case letters. No underscores, no hyphens. Anything else will cause the WYSIWYG editor to malfunction. (As of 3.6.1 you can use underscores in the ID.)
  • Once instantiated, the WYSIWYG editor cannot be moved around in the DOM. What this means in practical terms, is that you cannot put it in meta-boxes that can be dragged and placed elsewhere on the page. Instead use 'edit_page_form' (for pages) or 'edit_form_advanced' (for other post types):
add_action( 'edit_page_form', 'my_second_editor' );
function my_second_editor() {
	// get and set $content somehow...
	wp_editor( $content, 'mysecondeditor' );
  • When saving wp_editor data using $wpdb use wp_kses_post to allow html tags

Change Log

Source Code

wp_editor() is located in wp-includes/general-template.php


Editor Functions: wp_editor(), the_editor(), wp_default_editor(), user_can_richedit()