Site logo

Archived topic

Load editor-stylesheet after gp inline styles

3 replies · Started by AM on August 13, 2021

Viewing posts 1–4 of 4

Hi,
I'd like to load the editor-stylesheet in my child theme after generate-block-editor-styles-inline-css.
This post suggests that it should be loaded last. But I guess that's for the front-end, since in the editor it loads before the gp inline styles.

I'm enqueuing my editor-stylesheet according to this post. And I tried to name generate-block-editor-styles-inline-css as a handle, but that failed and let my editor-stylesheet disappear.

The following code returns my editor-stylesheet before the inline css.

function my_editor_styles(){
    wp_enqueue_style( 'my-editor-style-handle', get_stylesheet_directory_uri() . "/theme-styles/editor-styles.css", false, '1.0', 'all' );
}
add_action( 'enqueue_block_editor_assets', 'my_editor_styles');

The following code makes my editor-stylesheet disappear.

function my_editor_styles(){
    wp_enqueue_style( 'my-editor-style-handle', get_stylesheet_directory_uri() . "/theme-styles/editor-styles.css", array( 'generate-block-editor-styles-inline-css' ), '1.0', 'all' );
}
add_action( 'enqueue_block_editor_assets', 'my_editor_styles');

Any suggestions for a solution? Right now I'm using !important, but that's pretty ugly.
Thanks in advance.

Hi there,

not sure but try increasing the priority of your add_action eg.

add_action( 'enqueue_block_editor_assets', 'my_editor_styles');

becomes:

add_action( 'enqueue_block_editor_assets', 'my_editor_styles', 100);

It should hook you're request in later, you can increase the 100 value if it still doesn't work. But you should be able to see if its moved down the list.

Thanks. Had to set it to 200, but then it worked.

Glad to hear that!

This archived topic is closed to new replies.