Understanding child theme functions.php

What I read is that the parent css was loaded after the child, so the
last one wins

It depends on the order in which theme developer is loading stylesheets.

Normally WordPress loads child theme’s functions.php first and then parent theme’s functions.php.

the parent Emmet theme uses CSS files called differently than
Style.css

Yes it does. The style.css in the root folder of the theme is only needed for WordPress to properly identify the theme from it’s header.

style.css doesn’t need to be enqueued if doesn’t have any CSS properties other than theme header.

We can use any other name for the stylesheets and load them differently but style.css with theme header need to be there in the root folder to be identified as a theme by WordPress.

Normally some theme developers like to organize all the stylesheets in css folder, this is also the case used by the Emmet Lite theme developer.

wp_enqueue_style( $parent_style, get_template_directory_uri() . '/style.css'     );

you don’t need to enqueue the above parent style.css since it doesn’t have any CSS rules.It’s just a overhead.

Then how it’s working now ?

If we take a look at parent theme’s functions.php , we can see that it loads stylesheets in the following order.

  • Bootstrap
  • Font Awesome
  • Flex Slider
  • Main Style ( /css/emmet-style.min.css )
  • Finally stylesheet uri ( which basically means active theme’s style.css)

So here the parent theme is loading the required /css/emmet-style.min.css file first and then loadin the style.css , this is the style.css of the active theme, in your case child theme’s style.css.So you don’t even need to use the following code as it is already done by the parent theme.

wp_enqueue_style( 'child-style',
    get_stylesheet_directory_uri() . '/style.css',
    array( $parent_style )
);

Paths