1

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
  • You can add as many CSS files in your theme. Use wp_enqueue_style hook. Commented Feb 24, 2015 at 12:14

1 Answer 1

1

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' ) );
}
2
  • Why the 1.0 parameter in the animate line? Commented May 22, 2019 at 23:10
  • 2
    Technically, 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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.