If you created a new WordPress child theme from scratch and the parent style.css doesn’t load, the solution is here.
Create or edit the functions.php file in your child theme’s directory and add one of the following code to your child theme’s functions.php file.
Enqueue only parent styles:
// Enqueue parent theme styles
function child_theme_enqueue_styles_code_paste() {
// handle in my case $parent_style = 'neve-style'
$parent_style = 'parent-style';
wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );
}
add_action( 'wp_enqueue_scripts', 'child_theme_enqueue_styles_code_paste' );
Enqueue both parent and child styles:
// Enqueue both parent and child styles
function child_theme_enqueue_styles_code_paste() {
// handle in my case $parent_style = 'neve-style'
$parent_style = 'parent-style';
wp_enqueue_style( $parent_style, get_template_directory_uri() . '/style.css' );
wp_enqueue_style( 'child-style',
get_stylesheet_directory_uri() . '/style.css',
array( $parent_style )
);
}
add_action( 'wp_enqueue_scripts', 'child_theme_enqueue_styles_code_paste' );
How to find parent handle Name?
You can find your parent style handle name simply from the page source. The “id” attribute of the link tag is the handle name of the file without “-css”:
In my case the handle name of the file is “neve-style”. When you use the correct handle name it prevent duplicate insert of the file.