最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

themes - Why wp_enqueue_style() not working?

programmeradmin1浏览0评论

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 badges
Add a comment  | 

3 Answers 3

Reset to default 5

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.

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

发布评论

评论列表(0)

  1. 暂无评论