Additional stylesheets are required and should recommend to design a child theme. You can even add an additional stylesheet for different contents separately.
Method 1.
Step 1. Create a file custom.css under child theme and place some stylesheet info if you want.
/* Theme Name: Custom Theme CSS Theme URI: https://example.com/ Description: This is the custom css created for the Example. Author: Your Name Author URI: https://www.yourname.com/ Version: 1.0.0 Tags: Custom, addiitonal Template: genesis License: GPL-2.0+ License URI: http://www.gnu.org/licenses/gpl-2.0.html */ /* Start writing Custom CSS ---------------------------------------------------------------- */
Step 2. Once, the custom CSS file is created, it is time to show it on site. Add this code in functions.php
//* Load custom style sheet add_action( 'wp_enqueue_scripts', 'load_custom_style_sheet' ); function load_custom_style_sheet() { wp_enqueue_style( 'custom-stylesheet', get_stylesheet_directory_uri() . '/custom.css', array(), '1.0.0', 'all' ); }
Method 2.
You can simply show the CSS file using one line of code
//* Display Custom Style CSS wp_enqueue_style( 'custom-style', get_stylesheet_directory_uri() . '/custom.css' );
Note:- This will not overwrite the CSS, it simply enqueue the file. Please use the method 1 to ensure that your custom file is overwriting your CSS.
Method 2 works well when you have had to show additional features without interfering the default style.css file.
Like you have to show different features and the best possible way to do is to use a different file name for each feature.
Additional:-
If you want to add CSS file in other folder you can create a folder ‘css’ under public_html and create custom.css file and use this snippet in functions.php
//* Load custom style sheet add_action( 'wp_enqueue_scripts', 'custom_load_custom_style_sheet' ); function custom_load_custom_style_sheet() { wp_enqueue_style( 'custom-stylesheet', '/css/custom.css', array(), '1.0.0' ); }
//* Load custom style sheet add_action( 'wp_enqueue_scripts', 'load_custom_style_sheet', 100 ); function load_custom_style_sheet() { wp_enqueue_style( 'custom-stylesheet', get_stylesheet_directory_uri() . '/custom.css', array(), CHILD_THEME_VERSION, 'all' ); }
Note:- Make sure to check the path of the file in the source and the changes you have added.
Here How you can load stylesheet conditionally.
Reference: