0

我正在尝试用我的 style.css 覆盖引导程序(默认放置在我的 wordpress 主题文件夹中)。所以这是我在functions.php中的代码,用于将引导cdn和我的css排入队列:

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');

这就是我的头在我的谷歌检查员中的样子:

<link rel="stylesheet" id="maincss-css" href="http://bootstraptest.co.nf/wp-content/themes/HipsterTheme/style.css?ver=1.0.0" type="text/css" media="screen">

<link rel="stylesheet" id="bootstrap-css-css" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css?ver=4.2.3" type="text/css" media="all">

我对wordpress很陌生,所以对我好一点:P

4

1 回答 1

2

根据文档wp_enqueue_style,您应该使用$deps参数声明maincss的依赖关系,如下所示:

wp_enqueue_style( 'maincss', get_template_directory_uri() . '/style.css',array('bootstrap-css') );
于 2015-08-03T19:39:53.153 回答