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
body{background:green;}
But this code is not working
Can someone explain what i am doing wrong here ?
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
body{background:green;}
But this code is not working
Can someone explain what i am doing wrong here ?
Share Improve this question edited Mar 15, 2017 at 11:38 beginner asked Mar 15, 2017 at 11:04 beginnerbeginner 1252 silver badges10 bronze badges3 Answers
Reset to default 5Are 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.
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.
Added wp_head()
and wp_footer()
in header.php and footer.php file
and make sure make file functions.php to add your files using this two function wp_enqueue_style
and wp_enqueue_script