In this article, we learn about how to customize wp_editor in WordPress.
Here is the syntax:
wp_editor( $text, $id, $arg );
- $text(string): Your textarea content.
- $id(string): Your textarea id.
- $arg(array): your wp editor settings.
Here is some arg list:
- wpautop (true | false): If true auto paragraph enable.
- media_buttons (true | false): If true media button enable.
- textarea_name (string): Name of your textarea.
- textarea_rows: Textarea rows.
- tabindex: tabindex used for the form field.
- editor_css: add your css using <style> tag.
- editor_class: add your custom class.
- teeny (true | false): If true hide minimal editor.
- tinymce (true | false | array ): If false hide visual editor.
- quicktags (true | false | array ): If false hide text editor.
Here is some example:
- Hide visual editor and hide some text editor button.
$content = 'Your custom text'; $id = 'thecodehubs_bar_id'; $arg = array( 'textarea_name' => 'thecodehubs_bar_text', 'tinymce' => false, 'quicktags' => array( 'buttons' => 'strong,em,link,ul' ) ); wp_editor( $content, $id, $arg );
Output:
- hide some visual editor buttons.
$content = 'Your custom text'; $id = 'thecodehubs_bar_id'; $arg = array( 'textarea_name' => 'thecodehubs_bar_text', 'tinymce' => array( 'toolbar1'=> 'bold,italic,underline,bullist,numlist,link,unlink,forecolor,undo,redo,', 'toolbar2'=> '', ) ); wp_editor( $content, $id, $arg );
Output:
- Hide Media button.
$content = 'Your custom text'; $id = 'thecodehubs_bar_id'; $arg = array( 'textarea_name' => 'thecodehubs_bar_text', 'media_buttons' => false, ); wp_editor( $content, $id, $arg );
Also, you can create your custom tag in the text editor. For more detail read this article.