- This topic has 9 replies, 3 voices, and was last updated 3 years, 7 months ago by Martin.
-
AuthorPosts
-
April 17, 2017 at 7:17 am #306832Peter
I am using the child theme you provide on your site and save my CSS to its style.css.
Apparently the child theme’s
style.css
is loaded before the style sheets from the GP Premium add-ons, so styles with the same specifity are being overwritten.Is there any way to load the child theme’s CSS after the other style sheets?
April 17, 2017 at 8:56 am #306857LeoStaffCustomer SupportHi Peter,
Just making sure you are not enqueue the parent style sheet? The theme loads it automatically for you:
https://docs.generatepress.com/article/child-theme-issues/Let me know if this helps.
April 17, 2017 at 9:01 am #306863TomLead DeveloperLead DeveloperSome stylesheets might be added after the child stylesheet, but you can counter that by making your CSS more specific.
For example, add body in front of your custom CSS:
body .site-header { margin-top: 10px; }
April 17, 2017 at 2:27 pm #306996PeterApril 17, 2017 at 8:58 pm #307093TomLead DeveloperLead DeveloperAny reason why?
You could try this:
add_action( 'wp_enqueue_scripts', 'tu_child_scipts', 999 ); function tu_child_scipts() { wp_dequeue_style( 'generate-child' ); wp_enqueue_style( 'generate-child', get_stylesheet_uri(), array( 'generate-style' ), filemtime( get_stylesheet_directory() . '/style.css' ), 'all' ); }
April 18, 2017 at 12:29 pm #307434PeterThanx a lot, the
add_action
did the trick. The snippet dequeues the style sheet from the child theme and then loads all GP-stylesheets in an array sorting them by time stamp?>> [specificity] that’s precisely what I wanted to avoid
> Any reason why?Starting every selector with something like
body
just to increase specificity somehow feels, uhm, wronggg. Changing the load order seems cleaner.April 18, 2017 at 6:54 pm #307519TomLead DeveloperLead DeveloperIt simply removes the stylesheet and then re-adds it. The trick is the hook priority being set to 999 which is later than anything else. That loads it after all of the other hooks.
I see your point 🙂
August 19, 2020 at 7:44 am #1409501Nici know its an old thread but had the same problem in 2020. need to dequeue and requeue my own style.css because it was loaded before sticky.min and GP style. therefore overwriting some css rules was complicated. custom style.css from child theme should always loaded at last.
August 19, 2020 at 1:02 pm #1410085TomLead DeveloperLead DeveloperThis is a tough one to fix on our end now, unfortunately. If we were to force it to load after everything at this point, there’s a high probability people might run into issues with their CSS after updating.
September 22, 2020 at 11:25 pm #1454778Martin*deleted*
-
AuthorPosts
- You must be logged in to reply to this topic.