September 6, 2022
浏览次数 :  20




wp_editor( string $content, string $editor_id, array $settings = array() )



$settings array Required

Array of editor arguments.

  • wpautopboolWhether to use wpautop() . Default true.
  • media_buttonsboolWhether to show the Add Media/other media buttons.
  • default_editorstringWhen both TinyMCE and Quicktags are used, set which editor is shown on page load. Default empty.
  • drag_drop_uploadboolWhether to enable drag & drop on the editor uploading. Default false.
    Requires the media modal.
  • textarea_namestringGive the textarea a unique name here. Square brackets can be used here. Default $editor_id.
  • textarea_rowsintNumber rows in the editor textarea. Default 20.
  • tabindexstring|intTabindex value to use. Default empty.
  • tabfocus_elementsstringThe previous and next element ID to move the focus to when pressing the Tab key in TinyMCE. Default ':prev,:next'.
  • editor_cssstringIntended for extra styles for both Visual and Text editors.
    Should include <style> tags, and can use “scoped”. Default empty.
  • editor_classstringExtra classes to add to the editor textarea element. Default empty.
  • teenyboolWhether to output the minimal editor config. Examples include Press This and the Comment editor. Default false.
  • dfwboolDeprecated in 4.1. Unused.
  • tinymcebool|arrayWhether to load TinyMCE. Can be used to pass settings directly to TinyMCE using an array. Default true.
  • quicktagsbool|arrayWhether to load Quicktags. Can be used to pass settings directly to Quicktags using an array. Default true.


$content = "";
$custom_editor_id = "editorid";
$custom_editor_name = "editorname";
$args = array(
		'media_buttons' => false, // This setting removes the media button.
		'textarea_name' => $custom_editor_name, // Set custom name.
		'textarea_rows' => get_option('default_post_edit_rows', 10), //Determine the number of rows.
		'quicktags' => false, // Remove view as HTML button.
wp_editor( $content, $custom_editor_id, $args );

$content就是get_post_meta你这个meta字段的值。$editor_id 是你提交到数据的form里面的Teatarea的name的值,也就是post的name.


//rich text
case ‘editor’ :
$content = ”;
if( !empty( $data ) ) $content = $data; elseif( !empty( $value[‘default’] ) ) $content = $value[‘default’];
wp_editor( $content, $option_name, array(‘textarea_rows’ => 6) );