With almost all of our themes all relevant stylesheets are enqueued via the function wp_enqueue_styles() or wp_enqueue_scripts() which allows us to keep all of our CSS and JS files in one location within the theme.

When it comes to child themes most people will go for the straight @import property which has never been a good idea and we prefer not to use it – so for child themes we have included the appropriate function to load the child theme’s stylesheet in addition to the parent theme’s stylesheets. Here’s the code that does the work for you automatically….

// Load style.css from child theme
if (is_child_theme()) {
wp_enqueue_style('strapvert_child', get_stylesheet_uri(), false, null);

All you have to do is create your child theme but don’t use @import as the parent theme will do it automatically for you – to see how this work, below is an example child theme you can use as a base to start you off.

Posted in: Tips And Tricks