Parent style.css not loaded in child theme when using Unite WP Theme

Hey guys,

Love the unite theme, great work! However, there are a few things I’d like to change. I followed the WP-guideline for creating a child theme which works good so far. I created my own style.css file for my child-theme, but it seems that not all parent-styles (from the parent style.css) are loaded. It only works if I include a @import url("…/unite/style.css"); in my child style.css, which is not best practice. If I do not include the @import line, the styles from my child-css are loaded, but not the parent-styles. I checked the get_template_directory_uri() and get_stylesheet_directory_uri(), they are correct.

This is my child functions.php:

<?php
function theme_enqueue_styles() {
    wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );
    wp_enqueue_style( 'child-style', get_stylesheet_directory_uri() . '/style.css', array( 'parent-style' ) );
}
add_action( 'wp_enqueue_scripts', 'theme_enqueue_styles' );
?>

I also attached my child style.css. Can you guys help me on that?

  • Andreas

Hi Andreas,

I hope you are well today and thank you for your question.

You can try using the following code in the functions.php file of your child theme to enqueue style properly.

// Queue parent style followed by child/customized style
add_action( 'wp_enqueue_scripts', 'func_enqueue_child_styles', 99);

function func_enqueue_child_styles() {
    wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );
    wp_dequeue_style('unite-style');
    wp_enqueue_style( 'unite-style',
        get_stylesheet_directory_uri() . '/style.css',
        array('parent-style')
    );
}

Best Regards,
Movin

Yes, works like a charm. Thanks very much! :slight_smile:

Regards,
Andreas

You are most welcome here :slight_smile: