Skip to content
Advertisement

Style.css not overwriting parent style.css although style.css and functions.php are set up

I have been trying to fix this for two days, looking at the different answers on here.

Whenever I edit css in the ‘Additional CSS’ editor in WP, I get the desired results. However, I can’t seem to do this from the style.css sheet. Not that I need to do it from there, but it indicates to me that my child theme is not set up properly.

My style.css file:

/*
Theme Name: Coblog-child
Template: coblog
Author: [name]
Description: Coblog Child
Version: 1.1.0.1588784301
Updated: 2020-05-06 16:58:21
*/

my functions.php:

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

any idea what is wrong within these two?

Thanks

Advertisement

Answer

You are only loading the parent-style in your functions.php. So you do not load the style.css of your child theme. To make it work, you will have enqueue your child theme’s stylesheet as well:

function child_theme_styles() {
    wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );
    wp_enqueue_style( 'child-theme-css', get_stylesheet_directory_uri() .'/style.css' , array('parent-style'));
}
add_action( 'wp_enqueue_scripts', 'child_theme_styles' );

For the template directory uri (parent theme)

get_template_directory_uri()

For the child theme directory uri

get_stylesheet_directory_uri()
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement