Enqueue Stylesheet into Editor

See your custom CSS tweaks in the editor.

This simple script will allow you to enqueue your child theme stylesheet into the Gutenberg editor so you can see your custom CSS while editing.

add_filter( ‘generate_editor_styles’, function( $editor_styles ) {
    $editor_styles[] = ‘style.css’;
    return $editor_styles;
} );

Note: In my child theme, the css file is named 'style.css'. If you have a different name for your child theme, you’ll need to place that in the code above where it says "/style.css".

Kyle Van Deusen

Co-founder of The Admin Bar Community, owner of OGAL Web Design, and a GeneratePress & GenerateBlocks enthusiast.

For official support, please visit the forums for GeneratePress or GenerateBlocks

If you're looking to have a website built with GeneratePress & GenerateBlocks, then visit my agency website.

2 thoughts on “Enqueue Stylesheet into Editor”

  1. Love your videos. You could use “enqueue_block_editor_assets” instead:


    add_action('enqueue_block_editor_assets', function () {
    wp_enqueue_style('current-theme', get_stylesheet_uri());
    });

    Reply
  2. You can also use it to add customizer css:

    add_action('enqueue_block_editor_assets', function() {
    wp_register_style('customizer-css', false);
    wp_enqueue_style('customizer-css');
    wp_add_inline_style('customizer-css', wp_get_custom_css());
    });

    Reply

Leave a Comment