Support Forums for LiveMesh Themes & Plugins › Forums › Appdev Theme Support › Child theme CSS overrides
- This topic has 5 replies, 3 voices, and was last updated 9 years, 3 months ago by
simhem74.
-
AuthorPosts
-
December 30, 2013 at 12:41 pm #3559
robinwo
MemberHi all,
I created a child theme, with its own style.css in which I import the parent CSS (the good way: http://codex.wordpress.org/Child_Themes).
When my site is loaded, the skin CSS overrides all my child CSS styling. The only way to prevent this is tagging everything in my child CSS as !important, not the best solution.
In framework.php I see that the hook for loading skin CSS requires the child CSS to be loaded first. This way the skin will always override the child CSS.
Any idea how I can make the child CSS load AFTER loading the skin CSS – without touching the code of the AppDev theme (as that’s what child themes are for)? Trying to just cancel the hook that calls the MO_Framework enqueue_styles() functions did not work.
Thanks!
Robin
January 1, 2014 at 6:25 am #3578Raghavendra
ModeratorHey – thanks for bringing this to my attention. I understand the issue and now I am not sure we can rely on standard way of creating the child theme to help override all the styles in the parent theme (the issue also exists with the child theme that gets shipped with appdev bundle). This is because the WP assumes you have all your styles in style.css file. Making the other CSS files to load earlier than style.css can easily break the layout since they assume to be building on top of what is defined in style.css.
For example, skin.css file needs to be sure that someone does not enter some default color value in style.css file which will override its styling and responsive.css needs to take precedence over style.css when the device width changes, otherwise it will have no effect.
The best way to solve this problem is to have this defined in the child theme functions.php file –
add_action('wp_print_styles', 'add_child_custom_styles'); function add_child_custom_styles() { wp_register_style('style-child-custom', get_stylesheet_directory_uri(). '/child-custom.css', array('style-skin-css'), false, 'all'); wp_enqueue_style('style-child-custom'); }
You will need to create a child-custom.css file in the child theme to make this work. If you now enter your CSS in the child-custom.css, things should work fine. The child style.css can still be used to override the some of the basic styling defined in style.css file. Hope this helps.
January 2, 2014 at 11:02 am #3588robinwo
MemberGreat, thanks!
Might be good to also fix this in a theme update, meet the the WP standards! 🙂
January 3, 2014 at 1:20 pm #3600Raghavendra
ModeratorHope we can resolve this in a good way – there are many reporting this for themes with multiple stylesheets in WordPress.org forums. Looks like the one suggested above is our best bet for now unless we try to move a single style.css model (that unfortunately would require significant refactoring of the theme framework and has its own minuses). Thanks
March 10, 2014 at 7:56 am #5104simhem74
MemberI does not work for me!?
My child functions.php looks like this: `<?php
add_action(‘wp_loaded’, ‘child_create_objects’, 11);
function child_create_objects() {
}
add_action(‘wp_print_styles’, ‘add_child_custom_styles’);
function add_child_custom_styles() {
wp_register_style(‘style-child-custom’, get_stylesheet_directory_uri(). ‘/child-custom.css’, array(‘style-skin-css’), false, ‘all’);
wp_enqueue_style(‘style-child-custom’);
}?>`
Do I need to add @import url(“../extinct/custom/custom.css”) to the child-custom.css also?
March 10, 2014 at 8:09 am #5105simhem74
MemberSorry, ignore my above post (#5104). Everything suggested regarding the child theme functions.php file and the child-custom.css in this thread works for me.
-
AuthorPosts
- The topic ‘Child theme CSS overrides’ is closed to new replies.