• Resolved mbrailer

    (@mbrailer)


    Hello:

    I’m attempting to create a child theme with a style.css for styling custom elements. However, my child style.css does not appear to be loading.

    My style.css begins like this:

    /*
    Theme Name: LGC Custom (Bento)
    Template: bento
    Text-Domain: bento-child
    */
    

    I have a functions.php file with the following:

    <?php
    add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_styles' );
    function my_theme_enqueue_styles() {
        wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );
    }
    
Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter mbrailer

    (@mbrailer)

    Update: I also notice that when I use the PHP code above in my functions.php file, the main Bento style.css loads twice, while the child theme’s style.css does not load at all.

    The code comes from the WordPress Codex and I’ve used this technique with other themes successfully, so I think that there must be something different about Bento that prevents this from working.

    Thread Starter mbrailer

    (@mbrailer)

    Solved: I forgot that WP now includes a function to input additional CSS in the Customizer, so I can enter my CSS that way instead of a child theme.

    However, it would still be useful if Bento could load a child style.css.

    Theme Author satoristudio

    (@satoristudio)

    Hey Mike,

    your child theme’s style.css is correct; in the child’s functions.php, you’ll need to use the full code given in the official child themes tutorial, namely the one that uses the correct handle (“bento-theme-styles”) for the parent theme and also enqueues the child’s styles:

    add_action( 'wp_enqueue_scripts', 'bento_child_enqueue_styles' );
    function bento_child_enqueue_styles() {
    	$parent_style = 'bento-theme-styles';
        wp_enqueue_style( $parent_style, get_template_directory_uri() . '/style.css' );
        wp_enqueue_style( 'child-style',
            get_stylesheet_directory_uri() . '/style.css',
            array( $parent_style ),
            wp_get_theme()->get('Version')
        );
    }

    Sincerely,
    Andrii / Satori Studio

    Thread Starter mbrailer

    (@mbrailer)

    Thank you so much. This worked.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Child theme style.css not loading’ is closed to new replies.