V
V
vampire4442016-02-19 16:34:37
PHP
vampire444, 2016-02-19 16:34:37

How to connect your styles to the WordPress editor?

You need to connect the styles of the site itself to the WordPress editor, so that when editing in visual mode, everything is displayed as it will be on the site. I found on the Internet (on wp-kama) that this can be done through the functions.php file, writing the following code there:

function my_theme_add_editor_styles() {
  add_editor_style( 'styles.css' );
}
add_action( 'current_screen', 'my_theme_add_editor_styles' );

But I didn't succeed. The styles were not applied, but at the top of the page (and in the admin panel on all pages, and on the site itself) this code was displayed in a line. What could be the problem? The functions.php file was empty before, or rather it did not exist at all.
PS: things have progressed a bit - the styles are connected (seemingly), the code from functions.php is no longer displayed. However, the styles are still not applied, i.e. they are connected, but the behavior of the elements is not affected in any way

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Igor Vorotnev, 2016-02-19
@vampire444

Where did you get the current_screen action from? Replace with: add_action( 'admin_init', 'my_theme_add_editor_styles' );

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question