add_editor_style()

Advertisement

While developing WordPress theme you see the message:

RECOMMENDED: add_editor_style() does not seem to be implemented properly.

The reason is your themes style.css load ONLY ON front end.
So, While writing article end user not have an idea how it looks on front end.


Image for: ## Why editor style is recommended? # Why editor style is recommended?

The reason is end user does not

The reason of editor style is to Show the post design / look in post editor window!


Top ↑

# How it editor style works? # How it editor style works?

Image for: ## How it editor style works? # How it editor style works?

Check below example to know how editor style works.

E.g. If your single post design is look like below screenshot:


With editor style support:

Without editor style support:


Top ↑

# Add editor style support? # Add editor style support?

Image for: ## Add editor style support? # Add editor style support?
/**
 * Added Editor Style
 */
function _theme_slug_setup() {
     add_editor_style( 'editor-style.css' );
}
add_action( 'after_setup_theme', '_theme_slug_setup' );

Top ↑

# Add RTL Support for Editor Style # Add RTL Support for Editor Style

Image for: ## Add RTL Support for Editor Style # Add RTL Support for Editor Style

For editor style RTL support! Save the file with FILE_NAME-rtl.css

E.g. editor-style.css then editor-style-rtl.css
E.g. assets/inc/editor-style.css then assets/inc/editor-style-rtl.css

Leave a Reply