Hi faglork. Your child theme has a style.css file which is automatically enqueued by the parent theme. Your custom CSS should be in that file.
I know … but this theme (hueman) uses BOTH a style.css and the above mentioned main.css:
“The main css stylesheet of the Hueman theme is located in /assets/front/css/main.css.
The main reason why the main stylesheet of the Hueman theme has been moved to another place is : minification.
Minification is a technique to compress a css file and therefore improve speed (page load time) of your website.”
Well, I don’t need that for development (it can be switched off, which I did) and afterwardsI can minify my css myself if I want to.
My child-theme style.css works well, no problem with that. But since I have to make extensive changes the main.css it is somewhat counterproductive to have the css declared in the main.css only to revoke it in the child-theme style.css. I’d rather change the css directly, if only for clarity of code.
Apart from that, the question remains:
AFAIK when I create the same structure in a child theme, the child theme data is used instead of the original theme data.
Why does this not work for
assets/front/css/main.css
?
Cheers,
Alex
this theme (hueman) uses BOTH a style.css and the above mentioned main.css
The style.css file does not contain any code; it is used for documentation.
it is somewhat counterproductive to have the css declared in the main.css only to revoke it in the child-theme style.css
Overriding the default theme CSS is the purpose of a child theme style.css file. Whether your changes are minimal or complex, that’s what a WP child theme is designed for.
I’d rather change the css directly, if only for clarity of code.
If you don’t use the theme stylesheet then you’d need to copy the entire main.css file to your child theme and make your modifications there. Otherwise you will be missing the styles your child theme style.css file doesn’t contain. Also, if you do copy the entire main.css file to your child theme, when the theme is updated, you’ll need to copy the entire theme main.css file to your child theme again and reapply your changes. This defeats the purpose of having a child theme.
Why does this not work for assets/front/css/main.css?
Because stylesheet and javascript files aren’t used the same way as theme template files. The parent theme and child theme files are enqueued by the theme using a theme function. If you don’t want to use the theme files then you need to dequeue them and then enqueue your own files.
https://codex.wordpress.org/Plugin_API/Action_Reference/wp_enqueue_scripts
Hi!
If you don’t use the theme stylesheet then you’d need to copy the entire main.css file to your child theme and make your modifications there. Otherwise you will be missing the styles your child theme style.css file doesn’t contain. Also, if you do copy the entire main.css file to your child theme, when the theme is updated, you’ll need to copy the entire theme main.css file to your child theme again and reapply your changes. This defeats the purpose of having a child theme.
If the original theme/theme css gets updated in a major way I’d have to reapply changes anyway.
Because stylesheet and javascript files aren’t used the same way as theme template files. The parent theme and child theme files are enqueued by the theme using a theme function. If you don’t want to use the theme files then you need to dequeue them and then enqueue your own files.
https://codex.wordpress.org/Plugin_API/Action_Reference/wp_enqueue_scripts
Aah … That’s what I overlooked. Thanks a lot!
Alex