简体   繁体   English

W3 Total Cache不合并/缩小子主题CSS

[英]W3 Total Cache does not combine / minify child theme CSS

I have a child theme and W3 Total Cache does all the combining and minification of all the parent theme's CSS files, but the style.css file of my child theme remains outside the combined and minified file. 我有一个子主题,W3 Total Cache完成了所有父主题的CSS文件的合并和缩小,但是我的子主题的style.css文件仍然位于合并和缩小的文件之外。 This also breaks my styles, because the order of inclusion of the CSS files is broken. 这也破坏了我的风格,因为CSS文件的包含顺序被破坏了。 This is how I have included the CSS files of the parent theme - I added the following line in my child theme's functions.php: 这就是我包括父主题的CSS文件的方式-我在子主题的functions.php中添加了以下行:

function theme_enqueue_styles() {

global $wp_styles;
$parent_style = 'parent-style';

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 )
);
}
add_action( 'wp_enqueue_scripts', 'theme_enqueue_styles' );

Is there another way of linking the CSS files so that they get properly intercepted by W3 Total Cache? 还有另一种链接CSS文件的方式,以使它们被W3 Total Cache正确拦截吗?

Try enabling @import handling for child themes . 尝试为子主题启用@import处理

You also dont need to enqueue the style.css for child theme as its enqueued by default. 您也不需要将style.css作为子主题的缺省队列。 Instead just enqueue the parent stylesheet. 而是仅排队父样式表。

// Child-theme Functions.php
function theme_enqueue_styles() {

    global $wp_styles;
    $parent_style = 'parent-style';
    wp_enqueue_style( $parent_style, get_template_directory_uri() . '/style.css' );

}
add_action( 'wp_enqueue_scripts', 'theme_enqueue_styles' );

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM