• I am trying to make a child theme based on twentytwenty.

    I have used the code below to add the parent styles.

    function main_child_style() {
    
        /*Enqueue The Main twentytwenty Styles*/
        wp_enqueue_style( 'main_styles', get_template_directory_uri() . '/style.css' ); 
    
    }
    add_action( 'wp_enqueue_scripts', 'main_child_style' );
    
    

    That works, but I want to add some more styles in a separate directory like /assets/css/morestyle.css

    I have tried playing around with the function above, but it will not load the styles.

    How do I load more styles into my child theme?

Viewing 1 replies (of 1 total)
  • Did you read the Theme Handbook section on child themes? A few months ago, I put more details there about loading style sheets.
    The way you have coded yours, you will load two copies of the twentytwenty style sheet, because you used a different handle (the first parameter) than the parent theme did.

    Basically, you need another call to wp_enqueue_style() using different
    parameters for your other style sheet.
    Be sure to read about the parameters here: https://developer.www.ads-software.com/reference/functions/wp_enqueue_style/
    Your other style sheet needs a unique handle, a path, and a dependency on the style sheet you want it to be loaded after. A version parameter will help your visitors get the correct copy when you make changes (otherwise they get the one the browser cached).

Viewing 1 replies (of 1 total)
  • The topic ‘How to add ADDITIONA:L stylesheets to child themes?’ is closed to new replies.