Noob at wordpress development. Trying to create a child theme for a client. But the problem is that there are many css files and not one as per many tut's available, in my senario there are multiple css files. Can somebody help me in giving high level overview of how to create a child theme.
1 Answer
Your question is general, so I cannot answer it in details.
If the parent theme enqueues some styles using get_stylesheet_directory_uri() in the path they won't be available in child theme. Then you should enqueue lacking stylesheets in your child's function.php using get_template_directory_uri() which will point to the parent theme directory.
Some example:
add_action( 'wp_enqueue_scripts', 'wpse179217_enqueue_styles' );
function wpse179217_enqueue_styles() {
wp_enqueue_style( 'parent_name-style', get_template_directory_uri() . '/style.css' );
wp_enqueue_style( 'parent_name-odometerstyle', get_template_directory_uri() . '/css/odometer-theme-default.css', array(), '' );
wp_enqueue_style( 'parent_name-animate', get_template_directory_uri() . '/css/animate.css', array(), '1.0' );
wp_enqueue_style( 'child_name-style', get_stylesheet_uri(), array( 'parent_name-style' ) );
}
-
-
2Technically, it can by any string but its purpose is to mark a version number - theme, plugin or library, depending on the context - and to force refresh on browser cache when it's changed. Commented May 24, 2019 at 9:34
wp_enqueue_style
hook.