在您孩子的主题中function.php 文件中,找到enqueue函数并将其添加到那里,而不是使用@import 在CSS中。
例如:
function my_scripts_and_styles() {
wp_enqueue_style( \'main-style\', get_stylesheet_uri() );
wp_enqueue_style( \'bootstrap-style\', get_template_directory_uri() . \'/css/bootstrap.min.css\', array( \'main-style\', \'\', true );
if ( is_singular() && comments_open() && get_option( \'thread_comments\' ) ) {
wp_enqueue_script( \'comment-reply\' );
}
}
add_action( \'wp_enqueue_scripts\', \'my_scripts_and_styles\' );
此函数的作用是加载
style.css 文件,然后加载
bootstrap.min.css 只有
style.css 已成功加载(注意:它假定
bootstrap.min.css 位于
/wp-content/themes/{your theme}/css 因此,相应地调整代码。
wp_head() 从那里开始。如果首先需要引导加载,请移动array() 参数到main-style 并将内容更改为\'bootstrap-style\'.