• 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.

Viewing 3 replies - 1 through 3 (of 3 total)
  • I think there should not be space in your
    wp_enqueue_style( 'css parent', get_template_directory_uri() . '/css/style.css' );

    can you try all those name with _ or –

    wp_enqueue_style( 'css-parent', get_template_directory_uri() . '/css/style.css' );

    Thread Starter nateonawalk

    (@natesirrah)

    Thanks for the suggestion gorakh.sth — adding dashes “-” in the places where spaces were did not seems to make a difference in functionality. Any other hunches?

    Thread Starter nateonawalk

    (@natesirrah)

    Update: I’ve tried with and without dashes, spaces, and underscores now — doesn’t seem to be making a difference. If anyone has any ideas or needs other info, I’d really appreciate help :). Thanks!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Cannot Get CSS Files to Enqueue Correctly’ is closed to new replies.