Monday 17 July 2017

How to load Parent Style in Child Theme?

I have read about some articles regarding, how to call parent style sheet in your child theme, some prefer to load it in style using CSS import (Divi theme developers has choose this method) some has suggested to use the "wp_enqueue_scripts" hook (This hook use for both style and script files).

As you can see in this link in the Office forum of Divi Theme they suggest to use option of  to call parent theme style in child theme stylesheet.

And on Smashing Magazine article its mentioned that this is old concept of using the parent theme style in stylesheet, new approach is to load the stylesheet using the WP action wp_enqueue_scripts  in child theme functions.php file as mentioned in the below:

add_action( 'wp_enqueue_scripts', 'enqueue_parent_styles' );
function enqueue_parent_styles() {
   wp_enqueue_style( 'parent-style', get_template_directory_uri().'/style.css' );

I also would like to add that; Yes, the content mentioned in the both posts has too much time difference but wp_enqueue_scripts is way back old, I mean older than 2012. Also I have seen in some websites developed by other they prefer to use the old method, some use plugins to generate child theme which goes with same way.

In the latest post author has mentioned that the older approach is not recommended the reason is performance issue.

I will now leave up to you to decide which method you would like to go with.
Load disqus comments