wp_default_editor
Determines which editor (which tab) should be displayed by default: TinyMCE or HTML.
This filter lets you set the default editor tab by returning one of two values: tinymce (the Visual tab) or html (the Text tab). This forces a particular tab to be selected by default when a post is edited.
Normally, the most recently used tab is selected. If you edited a post in the visual editor, that preference is saved and the visual editor is selected the next time, and vice versa. This filter overrides that behavior and explicitly defines the default tab.

Usage
add_filter( 'wp_default_editor', 'wp_kama_default_editor_filter' );
/**
* Function for `wp_default_editor` filter-hook.
*
* @param string $r Which editor should be displayed by default. Either 'tinymce', 'html', or 'test'.
*
* @return string
*/
function wp_kama_default_editor_filter( $r ){
// filter...
return $r;
}
- $r(string)
- Editor type to select by default. Possible values:
tinymce,html,test.
Examples
#1 Set the default editor tab
Place one of the following snippets in the theme's functions.php file to always select the specified editor tab by default:
# Set the visual editor as the default editor.
add_filter( 'wp_default_editor', create_function('', 'return "tinymce";') );
# Set the HTML (text) editor as the default editor.
add_filter( 'wp_default_editor', create_function('', 'return "html";') );
#2 Select a default tab only when editing specific post types
This example sets the HTML editor as the default only for the post, func, and hook post types:
## Default text editor. Selects the text editor tab even if the TinyMCE tab was selected previously.
add_filter( 'wp_default_editor', function( $type ){
// Only for the specified post types.
$html = in_array( get_current_screen()->post_type, array('post','func','hook') );
return $html ? 'html' : $type;
});Changelog
| Since 2.5.0 | Introduced. |
Where the hook is called
return apply_filters( 'wp_default_editor', $r );