Cannot Get CSS Files to Enqueue Correctly
-
I’m running a theme that includes all of its actual effective stylesheets in a /css/ directory, including a “style.css” that contains all the CSS rules of the theme. I’m attempting to learn the proper way to enqueue a stylesheet instead of the @import rule with my child theme, but am really struggling!
At present I have a normal child theme style.css and a functions.php that contains the following:
<?php function theme_enqueue_styles() { wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' ); wp_enqueue_style( 'css parent', get_template_directory_uri() . '/css/style.css' ); wp_enqueue_style( 'css min', get_template_directory_uri() . '/css/style.min.css' ); wp_enqueue_style( 'css blue', get_template_directory_uri() . '/css/style-blue.css' ); wp_enqueue_style( 'css blue min', get_template_directory_uri() . '/css/style-blue.min.css' ); wp_enqueue_style( 'css green', get_template_directory_uri() . '/css/style-green.css' ); wp_enqueue_style( 'css green min', get_template_directory_uri() . '/css/style-green.min.css' ); wp_enqueue_style( 'css orange', get_template_directory_uri() . '/css/style-orange.css' ); wp_enqueue_style( 'css orange min', get_template_directory_uri() . '/css/style-orange.min.css' ); wp_enqueue_style( 'css violet', get_template_directory_uri() . '/css/style-violet.css' ); wp_enqueue_style( 'css violet min', get_template_directory_uri() . '/css/style-violet.min.css' ); wp_enqueue_style( 'css yellow', get_template_directory_uri() . '/css/style-yellow.css' ); wp_enqueue_style( 'css yellow min', get_template_directory_uri() . '/css/style-yellow.min.css' ); wp_enqueue_style( 'child-style', get_stylesheet_uri(), array('parent-style') ); } add_action( 'wp_enqueue_scripts', 'theme_enqueue_styles' ); ?>
But the CSS changes I’m making in my child’s CSS are overwritten (inspect element shows that they are applied but the parent theme’s stylesheet is applied afterward). What am I doing wrong? Thank you in advance for any help!
**I’m developing locally, so I can’t link to my site atm.
- The topic ‘Cannot Get CSS Files to Enqueue Correctly’ is closed to new replies.