I am working inside child theme.
My style.css
file in the child theme works fine but my layout.css
file does not work in the child theme.
Directory structure for layout.css
in parent theme is mytheme/css/layout.css
I’ve kept the same directory structure in child theme which is mychildtheme/css/layout.css
But when I write a code in child layout.css
, it doesn’t work.
Browser picks the code from parent theme (layout.css
)
Kindly let me know what must I do so that my layout.css
in child theme will work properly.
A stylesheet is different than a regular theme php file. With such a php file, it’s enough to create a file with the same name in your theme, and WP will know to use it. With css, however, it’s not enough to create a file with the same name. You have to explicitly include it into the pages you want.
The best way to do that would be using the wp_enqueue_style function in your child theme’s
function.php
file. Here is the way to do it given the directory structure you described:You need to include the layout.css file in your child theme.
For more detailed information, you can have a look here :
The best solution is to make sure that your child theme’s style.css is loaded after the parent theme’s layout.css. Then you can easily override the small things you need in the usual manner via style.css
Here is some code that works for WooThemes products, which ensures that your child theme css is always loaded after the parent child’s layout.css
It belongs in the child theme’s functions.php