In your child theme’s function.php
file, find the enqueue function and add it there instead of using @import
in your CSS.
For example:
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' );
What this function will do is load your style.css
file, then load bootstrap.min.css
only if style.css
is successfully loaded (NOTE: It assumes bootstrap.min.css
is located in /wp-content/themes/{your theme}/css
so adjust that code accordingly.
wp_head()
will take it from there. If you need bootstrap to load first, then move the array()
argument to main-style
and change the contents to 'bootstrap-style'
.