0

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 ?

6
  • To be clear, you see a network request to the style.css, the webserver just returns 404 for it? Can you access other asset files from your theme? (e.g. add a simple png and try to access that directly in the browser)
    – kero
    Apr 27, 2022 at 14:20
  • thanks @kero ; that's it, I see the request, but the server returns 404. I just added a snapshot.png in the child theme dir, with the right owner/perms, and I get a 404 in the browser Also, the snapshot doesn't show in the Appearance panel in wp-admin
    – Manumie
    Apr 27, 2022 at 14:31
  • This means it is not WP related, so out of scope for this stack, sorry. Sounds like your NGINX / PHP config is a bit messed up.
    – kero
    Apr 27, 2022 at 14:32
  • The thing is, I have another WP blog on the same server, same config (docker containers), and it works fine... the difference is that on the working side, the parent theme is twentyseventeen and not twentytwentytwo ; anyway I'll dig deeper in the nginx / php config...
    – Manumie
    Apr 27, 2022 at 14:34
  • 1
    Are you 100% sure the theme is mounted in the NGINX container as well? I've had this issue myself a couple of times, because it is easy to miss
    – kero
    Apr 27, 2022 at 15:00

1 Answer 1

1

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.

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