• I’m attempting to add styles to Gutenberg editor in a child theme, but add_editor_style() doesn’t seem to affect anything.

    functions.php:

    function style_editor() {
        add_theme_support( 'editor-styles' );
        add_editor_style( 'style-editor.css' );
    }
    
    // Remove the parent theme's editor styles function
    remove_action( 'after_setup_theme', 'twenty_twenty_one_setup' );
    add_action( 'after_setup_theme', 'style_editor' );
    

    style-editor.css:

    
    body {
        background-color: #fff;
        color: #000;
    }
    

    I’d expect this to work, but the only way to get it working is to go into the parent functions.php and comment out add_action( 'after_setup_theme', 'twenty_twenty_one_setup' );

    • This topic was modified 2 years, 9 months ago by jadamconnor.
Viewing 2 replies - 1 through 2 (of 2 total)
  • Hi @jadamconnor,

    You can remove the parent theme’s setup function in your child theme’s functions.php as follows:

    // Remove the parent theme's editor styles function
    add_action( 'after_setup_theme', function() {
    	remove_action( 'after_setup_theme', 'twenty_twenty_one_setup' );
    } ,0 );

    Let me know if this helps!

    Thread Starter jadamconnor

    (@jadamconnor)

    @kaavyaiyer This works. Thanks! Interesting… it looks like remove_action() is only invoked if it’s wrapped in a function?

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘add_editor_style() Seems to Do Nothing’ is closed to new replies.