child theme stylesheet
-
was just reading this how to enqueue a script/stylesheet: https://codex.www.ads-software.com/Plugin_API/Action_Reference/wp_enqueue_scripts
To make a theme compatible with child themes, you can use functions to determine the correct path to the core stylesheets ( without using @import in the CSS ):
function themeslug_enqueue_style() { if ( is_child_theme() ) { // load parent stylesheet first if this is a child theme wp_enqueue_style( 'parent-stylesheet', trailingslashit( get_template_directory_uri() ) . 'style.css', false ); } // load active theme stylesheet in both cases wp_enqueue_style( 'theme-stylesheet', get_stylesheet_uri(), false ); } add_action( 'wp_enqueue_scripts', 'themeslug_enqueue_style' );
I dont get it, aren’t the parent styles loaded before the child styles already? Isn’t that one of the purposes of adding a child theme? I mean, If I add a child theme, WHY would I add a function to check if I am on the child theme, in order to add first the parent styles? Just don’t get it.
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘child theme stylesheet’ is closed to new replies.