This code exists in the parent theme functions to load the child theme styles if the file exists but it is not loading at all even though the theme.css file is present in the child theme assets directory. The child theme is working otherwise.

 * Enqueue scripts and styles.
function nokul_editor_styles() {
    // Add the child theme CSS if it exists.
    if ( file_exists( get_stylesheet_directory() . '/assets/theme.css' ) ) {
add_action( 'admin_init', 'nokul_editor_styles' );

Am I missing something with this? Does the stylesheet have to be enqueued in the child theme functions still...?

1 Answer 1


Because you're using a subfolder path that starts with a /.

The official WP.org developer doc for add_editor_style has an example of how to add a stylesheet from a subfolder in the comments:

 * Registers an editor stylesheet in a sub-directory.
function add_editor_styles_sub_dir() {
    add_editor_style( trailingslashit( get_template_directory_uri() ) . 'css/editor-style.css' );
add_action( 'after_setup_theme', 'add_editor_styles_sub_dir' );


  • Ah this is interesting to learn but it doesn't seem to be doing anything. I've even tried a direct copy and paste of the code you referenced and it doesn't try to load that editor-style.css file. It's like add_editor_style isn't working at all but add_theme_support( 'editor-styles' ); is declared in the functions.
    – zigojacko
    Mar 17, 2023 at 13:44
  • @zigojacko Are you using the block editor or the classic editor? Mar 17, 2023 at 13:52
  • @JacobPeattie block editor and FSE
    – zigojacko
    Mar 17, 2023 at 13:54
  • did you change the css/editor-style.css part? Are there are 404's in the dev console when loading the editor? Have you tried wp_die( $the CSS URL so you can double check it )? And that the file you're using isn't in a PHP namespace?
    – Tom J Nowell
    Mar 17, 2023 at 18:20
  • and how are you testing if this does/doesn't work?
    – Tom J Nowell
    Mar 19, 2023 at 17:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.