Why is my child theme style.css not found (404) in the front-end?

I have a brand new Wordpress install (5.9.3) served by nginx (1.13.12).

I'm using Docker containers for nginx and wordpress.

I created a child theme based on twentytwentytwo following the WP codex instructions. It shows in the wp-admin and I was able to activate it and customize it through the block Editor.

Now I want to add a css class to my style.css. Here's the function to enqueue my child-theme's styles :

add_action( 'wp_enqueue_scripts', 'chesnaie_styles' );
function chesnaie_styles() {
    $parenthandle = 'twentytwentytwo-style';
    $theme = wp_get_theme();

    wp_enqueue_style(
        'chesnaie-style', 
        get_stylesheet_uri(),
        array( $parenthandle ),
        $theme-get( 'Version' )
    );
}

According to codex, I don't need to enqueue the parent's style :

If the parent theme loads its style using a function starting with get_template, such as get_template_directory() and get_template_directory_uri(), the child theme needs to load just the child styles, using the parent’s handle in the dependency parameter.

When I refresh the front-end to check my changes, I notice that my child theme's style.css is not loaded (I get a 404 not found).

I checked the files and directory permissions and ownership on the server, it's all set according to WP codex (755 for dirs and 644 for files), if I'm to believe this post. And it's identical to the parent's files.

I did refresh the permalinks (as advised in a related post) - though I'm not sure how that's relevant. And there's no caching plugin.

Still, the file returns 404. I can fetch the parent's style.css directly in the browser, but not my child-theme's.

Any hint ?

Topic docker child-theme css Wordpress

Category Web


You mentioned in the comments you can't access any files from the theme folder via the webserver. This usually means some configuration has gone wrong.

In docker / docker-compose the first thing that comes to mind is that the theme is not mounted into the webserver container.

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.