-
AuthorPosts
-
February 6th, 2016 at 04:45 #35502John
Hi, I am creating a child-theme for my site but the results have not been good so far. I’m following the WP instructions, but am still unclear about enqueueing the css files. I can see two css files in the root directory i.e. style and rtl. Do these both get enqueued or is style only sufficient? What about all the other css files in other directories – I could find five – should they all be enqueued? In the child theme I’m including a style.css and function.php. The latter has – <?php
add_action( ‘wp_enqueue_scripts’, ‘theme_enqueue_styles’ );
function theme_enqueue_styles() {
wp_enqueue_style( ‘parent-style’, get_template_directory_uri() . ’nirvana/style.css’ );
wp_enqueue_style( ‘rtl_basics-style’, get_template_directory_uri() . ’nirvana/rtl.css’ );
}
?>
…and this makes a mess of the menus and header, which I’m unclear how to correct. Any help please? Thanks, JohnFebruary 9th, 2016 at 21:37 #35543ZedCryout Creations mastermindSince the main style.css in the root is a special case, your child theme will need to enqueue this from the parent theme:
// enqueue parent theme styling function child_parent_styling(){ wp_enqueue_style( 'nirvana-parent', get_template_directory_uri() . '/style.css' ); // main style.css } add_action('wp_head','child_parent_styling', 4);
Other than that, the child theme only needs to enqueue the styles that it provides (since it inherits the parent’s functionality, parent styles will be enqueued by the existing code).
If you like our creations, help us share by rating them on WordPress.org.
Please check the available documentation and search the forums before starting a topic. -
AuthorPosts
The topic ‘Creating child theme – css enqueue’ is closed to new replies.