0

Can anyone help me how to add custom css file in wordpress.

I followed the below link, Where are Additional CSS files stored. But it shows only adding additional css, but i want to add css file and calling,

Thanks

2 Answers 2

2

Put this code in functions.php file for add new css file (more info here).

add_action( 'wp_enqueue_scripts', 'enqueue_my_styles' );
function enqueue_my_styles() {
    wp_enqueue_style( 'my-theme-ie', get_stylesheet_directory_uri() . "/css/ie.css");
}
  1. if using a parent theme then put code in parent theme function.php file and use get_template_directory_uri()
  2. if using a child theme then put code in child theme function.php file and use get_stylesheet_directory_uri()

Note: Relative CSS path must be correct.

0

Since you don't want to mess with the theme code/css (unless it's your own), it's best to create a child theme. Then you can put your additional CSS in the child theme's CSS file. Any CSS in there will override your parent theme's CSS.

Since you aren't changing the theme code/CSS (never a good idea), your changes will be kept when the theme has an update.

Many tutorials for creating and using a Child theme. Here's one ( a video) http://www.wpbeginner.com/wp-themes/how-to-create-a-wordpress-child-theme-video/ ; the googles will help you find other tutorials.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.