How to set WYSIWYG editor width within wp_editor() function?

There are two parameters that you can use to change the size of the text editor generated with wp_editor(), here there are:

$settings = array(
    'editor_height' => 425, // In pixels, takes precedence and has no default value
    'textarea_rows' => 20,  // Has no visible effect if editor_height is set, default is 20
);
  • If editor_height is provided, its raw value will be used
  • Otherwise textarea_rows (or it’s default value of 20) will be used to calculate the matching height in pixels

Good to know:

Here are a few examples of the result of the conversion from textarea_rows to pixels (this is done on the client side):

  • 0 to 3 => 100
  • 4 => 113
  • 5 => 133
  • 10 => 230
  • 15 => 328
  • 20 => 425

Leave a Comment