wordpress function.php无法加载css样式表

I've tried for hours to make wp_enqueue_style running when load in head part.

this is my code

function test_script(){

//Add Bootstrap Style
wp_enqueue_style('muarif-bootstrap',get_template_directory_uri().'/inc/css/bootstrap.css');

}
add_action('wp_enqueue_scripts','test_script');

But when i running my website, it's not load properly.

Here is my generated head

<head>
     <title>Muarif Gustiar | Web Developer - User Experience - Digital Marketing</title>
     <meta charset="UTF-8">
     <meta name="description" content="">
     <meta name="viewport" content="width=device-width,initial-scale=1.0">
     <meta http-equiv="content-type" content="text/html; charset=UTF-8">
     <style type="text/css"></style>
</head>

What wrong with my code? i follow the instruction to enqueue here. Any suggestion?

duanqiang6501
duanqiang6501 你确定get_template_directory_uri()。'/inc/css/bootstrap.css'指向正确的位置吗?
5 年多之前 回复

1个回答



Give this this </ p>

  function test_script(){

wp_register_style(“ bootstrapcss“,get_template_directory_uri()。”/ inc / css / bootstrap.css“);
nnnpp_enqueue_style('bootstrapcss');

}

add_action('wp_enqueue_scripts','test_script');
</ code> </ pre>
</ div>

展开原文

原文

Give this ago

function test_script(){

wp_register_style("bootstrapcss", get_template_directory_uri() . "/inc/css/bootstrap.css");

wp_enqueue_style('bootstrapcss'); 

}

add_action('wp_enqueue_scripts','test_script');

doushuangdui5419
doushuangdui5419 用get_stylesheet_directory_uri()更改get_template_directory_uri(),你应该是好的
5 年多之前 回复
douzhao2047
douzhao2047 还是行不通
5 年多之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐