i have a Issue, that my WordPress Site will only load 1 CSS File. I have 2 CSS Files: – My own Stylesheet – and the Bootstrap CSS File
I do import my JS File to, but this doesnt matter here, or does it?
I have the following Code in my header.php
File:
wp_register_style("style", get_template_directory_uri() . "/style.css", '', '1.0.0'); wp_enqueue_style('style'); wp_register_style("bootstrap.min", get_template_directory_uri() . "/bootstrap/css/bootstrap.min.css", '', '1.0.0'); wp_enqueue_style('bootstrap.min');
With this Code, only my Bootstrap File gets loaded, but when i change my Code to the Following(Comment the Bootstrap import):
wp_register_style("style", get_template_directory_uri() . "/style.css", '', '1.0.0'); wp_enqueue_style('style'); //wp_register_style("bootstrap.min", get_template_directory_uri() . "/bootstrap/css/bootstrap.min.css", '', '1.0.0'); //wp_enqueue_style('bootstrap.min');
my own Stylesheet is loading correctly, but the Bootstrap is not loading(cause its “commented” is this the right way to say in English?).
How can i load all 2 CSS Files correctly?
Advertisement
Answer
Add following code in your functions.php and check
function wpdocs_theme_name_scripts() { wp_register_style("style", get_template_directory_uri() . "/style.css", '', '1.0.0'); wp_enqueue_style('style'); wp_register_style("bootstrap-min", get_template_directory_uri() . "/bootstrap/css/bootstrap.min.css", '', '1.0.0'); wp_enqueue_style('bootstrap-min'); } add_action( 'wp_enqueue_scripts', 'wpdocs_theme_name_scripts' );