使用w3tc,引导程序cdn将覆盖缩小的css [英] minified css is getting overwritten by bootstrap cdn using w3tc
问题描述
我在wordpress上使用名为w3 total cache的插件来缩小我的style.css(它位于我的主题文件夹中)。问题是,在function.php我正确地像这样正确地插入了boostrap cdn和style.css:
$ b $ pre $ function bootstrap(){
wp_enqueue_style('bootstrap-css','https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css');
wp_enqueue_script('bootstrap-js','https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js',array('jquery'));
}
add_action('wp_enqueue_scripts','bootstrap');
function maincss(){
wp_enqueue_style('maincss',get_template_directory_uri()。'/style.css');
}
add_action('wp_enqueue_scripts','maincss');
但是,只要我的页面加载了style.css,在头标签和引导保持在下面之后覆盖我所有的规则......
这是我工作的网站: http://bootstraptest.co.nf
如果您在引导后立即移动第一个样式表,您可以看到该按钮正在工作,并且标头正在获取 header.php
add <$ c $ wp_head()
$ <! - W3TC-include-css - > b $ b
像这样:
<?php wp_head(); ?>
<! - W3TC-include-css - >
< / head>
这会导致在您的引导程序调用之后显示已开采的w3tc文件
i'm using a plugin called "w3 total cache" on wordpress that minifies my style.css (which is located in my theme folder). the problem is that in function.php i enqueued the boostrap cdn and style.css correctly like this:
function bootstrap() {
wp_enqueue_style( 'bootstrap-css','https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css' );
wp_enqueue_script( 'bootstrap-js', 'https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js', array('jquery') );
}
add_action('wp_enqueue_scripts', 'bootstrap');
function maincss() {
wp_enqueue_style( 'maincss', get_template_directory_uri() . '/style.css' );
}
add_action( 'wp_enqueue_scripts', 'maincss');
BUT, whenever my page loads the style.css gets minified right after the head tags and bootstrap stays below overwriting all my rules...
this is the website i'm working on: http://bootstraptest.co.nf
if you move the first stylesheet right after bootstrap you can see the button working and the header getting placed correctly.
In header.php
add <!-- W3TC-include-css -->
code after wp_head()
Like this:
<?php wp_head(); ?>
<!-- W3TC-include-css -->
</head>
This will cause the mined w3tc file to appear after your bootstrap call
这篇关于使用w3tc,引导程序cdn将覆盖缩小的css的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!