css – Custom block style not working in the editor

Question

I’m using the following code to register a custom block style for the quote block in a child theme:

function child_init() {
    register_block_style(
        'core/quote',
        array(
            'name'  => 'big-text-quote',
            'label' => __( 'Big Text Quote', 'textdomain' ),
            'style_handle' => 'child-block-styles',
        )
    );
}
add_action( 'init', 'child_init' );

function child_enqueue_block_assets() {
    wp_enqueue_style(
        'child-block-styles',
        get_stylesheet_directory_uri() . '/assets/css/blocks.css',
    );
}
add_action( 'enqueue_block_assets', 'child_enqueue_block_assets' );

According to the official WP docs, the enqueue_block_assets hook should enqueue the blocks.css file in both the frontend and the editor but, for some reason, the styles are not loaded in the editor.

I tried the enqueue_block_editor_assets hook to load the file in just the editor, but it’s not doing anything:

function child_enqueue_block_editor_assets() {
    wp_enqueue_style(
        'child-block-styles',
        get_stylesheet_directory_uri() . '/assets/css/blocks.css',
    );
}
add_action( 'enqueue_block_editor_assets', 'child_enqueue_block_editor_assets' );

What am I doing wrong?

0
leemon 2 months 2023-04-02T17:30:04-05:00 0 Answers 0 views 0

Leave an answer

Browse
Browse