The remove_editor_styles WordPress PHP function removes all visual editor stylesheets.
Usage
remove_editor_styles();
Parameters
- This function has no parameters.
More information
See WordPress Developer Resources: remove_editor_styles
- Implemented in version: 3.0.0
- Source code location: wp-includes/theme.php
Examples
Remove editor styles in a custom theme
Let’s say you want to remove editor styles in your custom WordPress theme. Add the following code to your functions.php file:
function my_theme_remove_editor_styles() {
remove_editor_styles();
}
add_action('init', 'my_theme_remove_editor_styles');
Remove editor styles conditionally
If you want to remove editor styles only for a specific user role, use the following code in your functions.php file:
function my_theme_remove_editor_styles_for_author() {
if (current_user_can('author')) {
remove_editor_styles();
}
}
add_action('init', 'my_theme_remove_editor_styles_for_author');
Remove editor styles on specific pages
To remove editor styles only on specific pages or posts, add the following code to your functions.php file:
function my_theme_remove_editor_styles_on_page() {
if (is_page('my-page-slug')) {
remove_editor_styles();
}
}
add_action('init', 'my_theme_remove_editor_styles_on_page');
Remove editor styles after a certain date
If you want to remove editor styles after a specific date, use the following code in your functions.php file:
function my_theme_remove_editor_styles_after_date() {
$today = date('Y-m-d');
$deadline = '2023-06-01';
if ($today >= $deadline) {
remove_editor_styles();
}
}
add_action('init', 'my_theme_remove_editor_styles_after_date');
Remove editor styles for specific post types
To remove editor styles only for specific post types, add the following code to your functions.php file:
function my_theme_remove_editor_styles_for_post_type() {
if (get_post_type() == 'my_custom_post_type') {
remove_editor_styles();
}
}
add_action('init', 'my_theme_remove_editor_styles_for_post_type');