- This topic has 7 replies, 3 voices, and was last updated 5 years, 2 months ago by
Tom.
-
AuthorPosts
-
December 12, 2015 at 8:33 am #159589
Leon
Hello,
I’ve created a child theme of Generate. The only content in
style.css
is info about my child theme. Infunctions.php
I’ve added this code:function rbt_styles() { wp_enqueue_style( 'child-style', get_stylesheet_directory_uri() . '/main.css' ); } add_action( 'wp_enqueue_scripts', 'rbt_styles' );
This loads my
main.css
file, but the default Generate stylesheet is overriding all my child theme styles. I thought WordPress loaded the parent theme’s styles before the child theme’s? I understand Generate sees I’m using a child theme and loads its own styles automatically?Do I need to load my child theme styles differently?
Thanks,
Leon
December 12, 2015 at 10:37 am #159608Tom
Lead DeveloperLead DeveloperYou actually don’t need to enqueue your stylesheet – GeneratePress does it for you.
Here’s a blank child theme: http://generatepress.com/api/themes/generatepress_child.zip
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentDecember 12, 2015 at 11:56 am #159630Leon
Thanks Tom,
That’s helpful. However, I’m using SASS to build my child theme stylesheet, so ideally I’d like to not use
style.css
at all. I think the ‘proper’ way to load an additional stylesheet (main.css
in my case) is to enqueue it?I guess I could output my SASS file to
style.css
, complete with the opening child theme comments? I’m not sure that would work if I compress the CSS.If I did this and still wanted to add stylesheets afterwards, will Generate allow this? Does it load additional stylesheets after the parent theme’s?
L
December 12, 2015 at 11:57 am #159631Tom
Lead DeveloperLead DeveloperGotcha! In that case, just add a later priority to your add_action call:
add_action( 'wp_enqueue_scripts', 'rbt_styles', 500 );
That will make your stylesheet show up after the others.
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentDecember 12, 2015 at 12:24 pm #159638Leon
Thanks Tom, that’s great. Should’ve RTFM more closely π
Thanks for your time. Really liking the theme: good typographic defaults, neutral and configurable enough to build stuff on.
L
December 12, 2015 at 12:32 pm #159642Tom
Lead DeveloperLead DeveloperGlad I could help! Thanks for using GP π
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentApril 19, 2017 at 5:44 pm #307965Jim
Thanks for this, I was wondering the same thing, because I’d like to pull the CSS tweaks out of the customizer and into a Sass’ified child theme as well.
April 19, 2017 at 9:21 pm #308020Tom
Lead DeveloperLead DeveloperGlad it was helpful to you as well π
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-development -
AuthorPosts
- You must be logged in to reply to this topic.