• Resolved stevegossett64

    (@stevegossett64)


    Just thought I would add. I forgot the website that helped put this together but here it is as I use in denaani child theme. Its commented.

    function my_theme_styles() {
        global $wp_styles;
        $parentOriginalHandle = 'twentytwelve-style';
        $parentNewHandle = 'parent-style';
    
        // Deregister our style.css which was enqueued by the parent theme so we control
        // the versioning ourself.
        $parentStyleVersion = $wp_styles->registered[$parentOriginalHandle]->ver;
        $parentDeps = $wp_styles->registered[$parentOriginalHandle]->deps;
        wp_deregister_style($parentOriginalHandle);
    
        // Enqueue the parent theme's style.css with whatever version it used instead
        // of @import-ing it in the child theme's style.css
        wp_register_style($parentNewHandle, get_template_directory_uri() . '/style.css',
            $parentDeps, $parentStyleVersion);
    
        // Enqueue our style.css with our own version
        $themeVersion = wp_get_theme()->get('Version');
        wp_enqueue_style($parentOriginalHandle, get_stylesheet_directory_uri() . '/style.css', [$parentNewHandle], $themeVersion);
    }
    // Run this action the parent theme has enqueued its styles.
    add_action('wp_enqueue_scripts', 'my_theme_styles', 20);
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)

The topic ‘Here is alternative for loading CSS than using Import’ is closed to new replies.