php – How to load multiple css files before the closing head tag?-ThrowExceptions

Exception or error:

I was wondering how to make this code work for 2 css files. We use the code below in functions.php to load in our own css just before the closing head tag, but we want to load in a second css just before the closing head tag. How do we make this code work for 2 css files?

function register_my_custom_styles() {
wp_register_style("boldbase-styles", "//boldbase.nl/l/wp-content/uploads/bb-style.css");
}

add_action("wp_enqueue_scripts", "register_my_custom_styles");

function styles_to_go_after_oxygen() {
wp_print_styles("boldbase-styles");
}
add_action("wp_head", "styles_to_go_after_oxygen", 1000000 ); 
How to solve:

You can load multiple CSS using only wp_enqueue_scripts action.

function load_styles() {
  wp_enqueue_style ("first style", "url/first-style.css", array(), null);
  wp_enqueue_style ("second style", "url/second-style.css", array(), null);
  wp_enqueue_style ("third style", "url/third-style.css", array(), null);
}
add_action('wp_enqueue_scripts', 'load_styles_scripts', 99999);

The stylesheets will be placed in the same order inside the <head> tag.

Leave a Reply

Your email address will not be published. Required fields are marked *