Child theme style.css not overriding parent
-
So we have a custom theme we’ve built and used for a while now. Given that there are times we use multiple stylesheets we have a dummy style.css located at theme/style.css (as a wordpress theme requires a stylesheetat root of the theme to function) however our pages import and reference a stylesheet in a folder located at theme/styles/main.css.
So that is the background info.
Now I’m trying to create a chile theme from my above theme. File structure is:
/theme
/child-theme
/child-theme/style.csschild theme has the following
/*
Theme Name: Theme-child
Description: Child theme for the theme
Template: theme
*/@import url(“../theme/styles/main.css”);
body{
#ccc
}I’m aware that in theme-child the style.css folder must be a root and must be named style.css.
This didn’t strike me as a problem as I planned to use the @import url(“../theme/styles/main.css”); to grab my parent stylesheet.
However this is not working. When i activate the child theme my body color is left unchanged.
Now before you jump the gun and tell me the stylesheet for the parent theme cannot be in a folder and must be at root let me tell you I’ve tried moving it out. Which looked like this.
/theme/
/theme/main.css
/theme-child/
/theme-child/style.cssFor those of you wondering I also renamed my parent theme stylesheet back to style.css and adjusted my @import path in the child-theme style.css accordingly.
With all that being said the child theme is funtional. I can activate it and the page loads fine. The issue still stand though that the child theme’s style.css is not overriding the parents. For instance to my understanding if I had a child theme that had a style.css with the following:
/*
Theme Name: Theme-child
Description: Child theme for the theme
Template: theme
*/the child theme should load with no style as I’ve not yet used @import to bring in the parent stylesheet.
yet when I try this even still the child theme load the parent’s style.css
I’ve confirmed in the wordpress theme editor that the child stylesheet located at them-child/style.css is there and being used as the stylesheet for the activated child-theme.
I find this odd it’s like the child-theme see it’s style.cc file enough to be an active usable theme, but it is not loading the style overrides contain with said file.
Can anyone please shine a light on what I might be doing wrong? I’ve tried every possible scenario I can think of and this doesn’t make any sense to me.
- The topic ‘Child theme style.css not overriding parent’ is closed to new replies.