Can you explain that why use this code:
wp_enqueue_style( ‘parent-style’, get_template_directory_uri() . ‘/style.css’ );
despite in other css files you recommend that dont use parent theme.
So the third parameter for wp_queue_style() is the dependency. That is, if the script that you are trying to load needs to come after another script, then you add the “handle” of that script as the third parameter.
So when you add this to load the parent style.css:
wp_enqueue_style( ‘parent-style’, get_template_directory_uri() . ‘/style.css’ );
The “handle” is the first parameter, ‘parent-style’. There is no third parameter because the parent style.css file isn’t dependent upon another CSS file, it can be placed anywhere.
For the child theme’s style.css file, you need to add this:
wp_enqueue_style( ‘child-style’,
get_stylesheet_directory_uri() . ‘/style.css’,
array(‘parent-style’)
);
The third parameter says that this child theme’s style.css file must come after the file whose handle is ‘parent-style’. So because you set the handle of the parent’s style.css file to ‘parent-style’, you need to set the third parameter of wp_enqueue_style for the child theme to ‘parent-style’.
Also i really surprised that you understand my style.css file doesnt load!
if it possible tell me how can you understand this.
I just did a view source on the page and searched for the word stylesheet. Here is what is currently there:
<link rel='stylesheet' id='jquery-colorbox-css' href='https://www.meroeh.com/wp-content/plugins/yith-woocommerce-compare/assets/css/colorbox.css?x36021' type='text/css' media='all' />
<link rel='stylesheet' id='yith-woocompare-widget-css' href='https://www.meroeh.com/wp-content/plugins/yith-woocommerce-compare/assets/css/widget.css?x36021' type='text/css' media='all' />
<link rel='stylesheet' id='bootstrap-css' href='https://www.meroeh.com/wp-content/themes/webmarket/assets/stylesheets/bootstrap.css?x36021' type='text/css' media='all' />
<link rel='stylesheet' id='jquery-ui-webmarket-css' href='https://www.meroeh.com/wp-content/themes/webmarket/assets/stylesheets/smoothness/jquery-ui-1.10.3.custom.min.css?x36021' type='text/css' media='all' />
<link rel='stylesheet' id='main-css' href='https://www.meroeh.com/wp-content/themes/webmarket/assets/stylesheets/main.css?x36021' type='text/css' media='all' />
<style id='main-inline-css' type='text/css'>
/* Custom CSS */
body.woocommerce-page ul.products li.product h3, .woocommerce ul.products li.product h3 {
min-height: 100px;
}
</style>
<link rel='stylesheet' id='child-style-main-css' href='https://www.meroeh.com/wp-content/themes/webmarket-child/assets/stylesheets/main.css?x36021' type='text/css' media='all' />
<link rel='stylesheet' id='child-style-bootstrap-css' href='https://www.meroeh.com/wp-content/themes/webmarket-child/assets/stylesheets/bootstrap.css?x36021' type='text/css' media='all' />
<link rel='stylesheet' id='parent-style-css' href='https://www.meroeh.com/wp-content/themes/webmarket/style.css?x36021' type='text/css' media='all' />
<link rel='stylesheet' id='child-style-css' href='https://www.meroeh.com/wp-content/themes/webmarket-child/style.css?x36021' type='text/css' media='all' />
I now see the parent and child style.css files down at the bottom of that list. Before, it wasn’t there.
Also, look at the line for the parent theme’s main.css. You’ll see the ID is ‘main-css’. That’s why you needed to use ‘main’ as the handle for the child theme’s main.css file, the handle is the part before ‘-css’.