I am new to wordpress, I am trying to develop a theme on localhost, I am trying to load style.css using this code in functions.php

function add_theme_scripts() {
 wp_enqueue_style( 'style', get_stylesheet_uri() );
 add_action( 'wp_enqueue_scripts', 'add_theme_scripts' );

And style.css is


But this code is not working

Can someone explain what i am doing wrong here ?


Are you sure you theme is active?

If you see your style.css code it should not have only the CSS code but also the Theme defination at header of your style.css.

Please make sure if your theme is active.

The above code for loading CSS file looks good and should work if your theme is active.

Update :

Have you added wp_head() and wp_footer() in header.php and footer.php respectively?

wp_head() should be added before </head> tag in your HTML and wp_footer() should be added before </body> tag in HTML.

  • It does have theme defination and theme is active , but still not working, what to do ? – beginner Mar 15 '17 at 11:13
  • Please check the updated answer – Aftab Mar 15 '17 at 11:17
  • 1
    Hey I just add wp_header() and wp_footer() , Now it is working, Thanks ! – beginner Mar 15 '17 at 11:50

Style.css is added by default when you make your theme. Why you want to add it through functions.php? You can also call any css in header.php also.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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