Load Child theme CSS first
When we are working with child theme, we are having separate CSS for parent theme any child theme. Generally we face some design issues for instant of time when the website is loading. In this case the CSS which we need to load is loading delay of few seconds.
To overcome this issue, we can set the priorities of CSS as per our requirement. Just place the below mentioned code in your function.php file :
// Code for loding priority for CSS files. add_action( 'wp_enqueue_scripts', 'my_child_theme_scripts', 20 ); function my_child_theme_scripts() { //echo get_template_directory_uri(); wp_enqueue_style( 'parent-theme-css', get_template_directory_uri() . '/style.css' ); } add_action( 'wp_enqueue_scripts', 'load_my_child_styles', 10 ); function load_my_child_styles() { //echo get_stylesheet_directory_uri()."</br>"; wp_enqueue_style( 'child-theme', get_stylesheet_directory_uri().'/assets/css/style.css' ); }
Leave a Reply