How to add a wordpress custom css file


Adding a custom css file to your wordpress theme is very easy. Adding a custom css file is very useful especially if you are not using a custom theme.

By using a custom css file, the changes you do to your website won’t be lost if an update in your theme occurs.

How to add a wordpress custom css file

First we have to add some code to the theme’s functions.php file. Open the file and add the below:

add_action(‘wp_enqueue_scripts’, ‘your_function_name’);

(This uses the add action hook, hooking into the wp_enqueue_scripts action.)

Then, you will need to add the function to your functions.php file that will utilize the WordPress function wp_enqueue_style:

function your_function_name() {
    wp_enqueue_style(‘my-script-slug’,  get_stylesheet_directory_uri() . ‘/your_style.css’);

Please note the use of get_stylesheet_directory_uri() – this gets the proper stylesheet directory for your theme.

Sharing is caring:
Share on facebook
Share on twitter
Share on pinterest
Share on linkedin

Leave a Reply

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

Hi I'm Rene Vigar

Hi, I’m Rene Vigar, a UX UI Designer with front-end development skills. Join me here, on for weekly tips and tutorials about UX UI Design and UI Development. I am also a part-time blogger writing for Medium, Forbes, Entrepreneur, Inc, Business Insider and more.