i'm trying to overwrite bootstrap with my style.css (placed by default in my wordpress theme folder). so this is the code i have in my functions.php to enqueue the bootstrap cdn and my 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');
and this is what my head looks like in my google's inspector:
<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">
i'm pretty new with wordpress so be nice to me :P
According to the documentation wp_enqueue_style, you should declare the dependency of maincss using the $deps parameter , like this:
wp_enqueue_style( 'maincss', get_template_directory_uri() . '/style.css',array('bootstrap-css') );